Fork me on GitHub
#clojure-uk
<
2018-12-11
>
folcon12:12:30

Morning :)…

folcon12:12:43

@otfrom Thanks! Will take a look

folcon12:12:35

Looking at the dates, not sure if we can respond >_<…

guy12:12:45

👋 hi friends

guy12:12:30

I’ve got a dumb question: Can someone explain to me why this happens?

(map #(%) [{:a 2} {:b 3}])
ArityException Wrong number of args (0) passed to: PersistentArrayMap  clojure.lang.AFn.throwArity (AFn.java:429)

(map (fn [x] x) [{:a 2} {:b 3}])
=> ({:a 2} {:b 3})

rickmoynihan12:12:43

% is the first argument of the form (%) and ({:a 2}) requires an argument

❤️ 4
4
guy12:12:54

Also how do i find the source code for #(..) so i can read it on github.

minimal12:12:36

the #(%) form always calls it as a function

☝️ 4
❤️ 4
minimal13:12:40

I’m can’t be sure as I’m not familiar with the reader code

guy13:12:40

ok cool thanks

alexlynham12:12:37

if you did #(identity %) it would work, no?

guy12:12:57

Yeah ^ i think so

bronsa12:12:39

but then just do identity :)

alexlynham12:12:05

I was trying to (badly) make the point minimal explained better haha 🙂

guy12:12:24

Oh it was more like i didnt know #(..) always calls it as a function

guy12:12:36

so it was just unexpected for me 🙂

rickmoynihan13:12:25

It’s just that #(foo ,,,) applies foo to the args. It’s just sugar for (fn [x] (foo x)). So the paren in #`(` is like the applying paren in (foo in the unsugared form.

👍 4
jasonbell14:12:33

(map #(clojure.string/upper-case %) ["thing" "thing" "thing" "thing"])

jasonbell15:12:25

I leave the room for 15 minutes….

danielneal15:12:46

we're helping

jasonbell15:12:29

@danieleneal I wasn’t implying you weren’t 🙂

bananadance 8