Fork me on GitHub
#beginners
<
2018-10-14
>
Nathaniel Stevens17:10:02

Would somebody be able to tell me why this doesn't work? (-> [1 2 3] (filter odd?))

bronsa17:10:59

try to macroexpand it

bronsa17:10:26

user=> (macroexpand-1 '(-> [1 2 3] (filter odd?)))
(filter [1 2 3] odd?)

dadair18:10:32

You need ->> is this particular case :)

Daniel Hines18:10:55

In the "Pull" section of the Datomic on-prem tutorial(https://docs.datomic.com/on-prem/tutorial.html#pull), db/pull returns data that looks like this:

#:inv{:color #:db{:ident :blue}, ...}
What is the the #:inv and #:db? I've yet to encounter this sort of data literal/syntax.

bronsa18:10:32

#:foo{:bar 1 :baz 2} is sugar for {:foo/bar 1 :foo/baz 2}

bronsa18:10:59

i.e. all the idents (keywords and symbols) used as keys in the map will be namespaced by the prefix

❤️ 4
Daniel Hines18:10:06

Oooooh. I had no idea. Cool. Thanks!

mbjarland20:10:35

assume I want to use some java 8 features in some piece of code if that code is running under java 8, but revert to a java 6 compatible code snippet when running under java 6. Would that be possible in clojure? And how? Conditional require call?

seancorfield20:10:58

@d4hines You'll probably find this section of the destructuring guide helpful too https://clojure.org/guides/destructuring#_namespaced_keywords

seancorfield20:10:39

And the reader literal syntax associated with maps is discussed here https://clojure.org/reference/reader#_maps

Daniel Hines21:10:01

@bronsa, @seancorfield, all of that is clarifying. Thanks!