Fork me on GitHub
#beginners
<
2022-03-09
>
ossosoi loso09:03:46

Style guidance wanted: is defining global functions through composition e.g. (def foo (comp b->c a->b)) bad style and should I use the more verbose defn instead for that purpose?

ossosoi loso09:03:10

Information about the inner function’s signature is lost in cursive it seems.

delaguardo10:03:05

that is completely fine. To preserve signature you could copy metadata of rightmost composed function (in your example a->b) to foo

(def ^{:arglists (:arglists (meta #'a->b))} foo
  (comp b->c a->b))

ossosoi loso10:03:08

That’s very useful thanks!

Adir Ohayon09:03:19

Hello everyone! Is there a clean way in Clojure to check if a string is plural or singular?

Ferdinand Beyer09:03:21

I don’t think something like this is built-in. There are many irregular plural forms in english. If something like this exists, it would be a library.

Ferdinand Beyer09:03:20

You might be able to wrap a Java library such as this: https://github.com/atteo/evo-inflector

Adir Ohayon09:03:12

Ty for the fast reply! figured that it'd be problematic but wanted to make sure I wasn't missing anything due to my faulty googling skills :') Cheers!

Ilana Omer11:03:14

Hi How Can I convert string representing a date to its long value?

jumar12:03:29

What do you mean by "long value"?

V12:03:00

Convert the string to an instant and use java interop

(.getEpochSecond instant)

Martin Půda13:03:59

(-> "09-03-2022"
    (LocalDate/parse (DateTimeFormatter/ofPattern "dd-MM-yyyy"))
    (.atStartOfDay)
    (.toInstant ZoneOffset/UTC)
    (.getEpochSecond))
=> 1646784000

Jimmy Alejandro Alvarez Calderon21:03:57

Hi guys, hope your are doing good. Currently looking in functional programming and interested in learning clojure, i wanted to know if you have any book recommendation where functional programming concepts are included?

Alex Miller (Clojure team)21:03:30

Most intro Clojure books probably include this to some degree, certainly Programming Clojure does

☝️ 1
Stuart21:03:55

Not all of it is relevant to Clojure, but I LOVED the Manning book Functional Programming in Scala. I don't even do any Scala, but I thought it taught some really good FP concepts better than any other book I've tried, in a language agnostic way.

djblue21:03:36

https://www.braveclojure.com/clojure-for-the-brave-and-true/ is a great read and has a few chapters explicitly on functional programming :thumbsup:

bravetrue 1
jumar04:03:36

I think Grokking Simplicity by @U050P0ACR is great