Live data from Hacker News

Learning Clojure: comparing with Java streams

blog.frankel.ch

1–10 of 46 posts

Re: Learning Clojure: comparing with Java streams

#2
It seems strange to me that `(map extract-name justice-league)` isn't listed under "idiomatic improvements." Supposing you already had `extract-name` defined for some reason, it's cleaner and simpler to just map that unary function than wrap that function in an anonymous function - whether that wrapping is done with the `#(...)` reader syntax or explicitly constructed with `fn`.

Re: Learning Clojure: comparing with Java streams

#3
post #2

It seems strange to me that `(map extract-name justice-league)` isn't listed under "idiomatic improvements." Supposing you already had `extract-name` defined for some reason, it's cleaner and simpler to just map that unary function than wrap that function in an anonymous function - whether that wrapping is done with the `#(...)` reader syntax or explicitly constructed with `fn`.

Oh that's a pet peeve of mine. Fun fact: it's called an eta expansion/reduction/conversion.

Re: Learning Clojure: comparing with Java streams

#5
post #2

It seems strange to me that `(map extract-name justice-league)` isn't listed under "idiomatic improvements." Supposing you already had `extract-name` defined for some reason, it's cleaner and simpler to just map that unary function than wrap that function in an anonymous function - whether that wrapping is done with the `#(...)` reader syntax or explicitly constructed with `fn`.

It certainly looks like a deliberate move to introduce anonymous functions and thus justify replacing the named function.

Re: Learning Clojure: comparing with Java streams

#6
post #2

It seems strange to me that `(map extract-name justice-league)` isn't listed under "idiomatic improvements." Supposing you already had `extract-name` defined for some reason, it's cleaner and simpler to just map that unary function than wrap that function in an anonymous function - whether that wrapping is done with the `#(...)` reader syntax or explicitly constructed with `fn`.

Or indeed `(map :name foo)` instead of the suggested (and redundant, linenoisy) `(map #(:name %) foo)`.

Re: Learning Clojure: comparing with Java streams

#9

> and Clojure’s syntax is pretty limited Erm, what? I am confused by the use of the word 'limited' in this context.

I confirm: the syntax is limited. There are only a few keywords and langage constructs. The power is in the number of functions made available, or the ones you create for yourself.
Post reply on HN