This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-10
Channels
- # aleph (4)
- # beginners (32)
- # cider (12)
- # cljs-dev (56)
- # cljsrn (7)
- # clojars (3)
- # clojure (165)
- # clojure-dev (33)
- # clojure-germany (1)
- # clojure-italy (27)
- # clojure-russia (7)
- # clojure-spec (24)
- # clojure-uk (62)
- # clojurescript (37)
- # core-async (7)
- # core-matrix (1)
- # cursive (9)
- # data-science (8)
- # datomic (8)
- # duct (4)
- # events (1)
- # figwheel (7)
- # flambo (3)
- # fulcro (43)
- # hoplon (25)
- # jobs-discuss (8)
- # lein-figwheel (4)
- # luminus (2)
- # off-topic (35)
- # om (8)
- # om-next (3)
- # onyx (30)
- # pedestal (62)
- # portkey (2)
- # protorepl (2)
- # re-frame (40)
- # reagent (9)
- # shadow-cljs (123)
- # specter (30)
- # sql (22)
- # testing (1)
- # uncomplicate (40)
- # unrepl (3)
- # vim (13)
- # yada (5)
månmån
Morning all
Just want to check my understanding is correct here. This is an experiment to replicate the functionality of (count coll)
as a learning exercise...
(reduce (fn [result _] (inc result)) 0 [1 4.0 :foo "bar"])
In this example ☝️, reduce
is in the form of (reduce f val coll)
f
is an anonymous function (`fn`) that is accepting two arguments.
In the first iteration, reduce
calls the anonymous fn
and passes it 0
which is assigned to result
, and the first element in the collection (`1` which is assigned to _
as we're not really concerned about storing this value).
Then inc
is applied to result
which returns a value of 1
back to reduce
.
Then reduce
takes this returned value of 1
, passes it to the anonymous fn
again as the result
argument, and the next item in the collection (e.g. (first (rest coll))
= 4.0
) as _
, repeats the inc
call on result
and returns 2
to the reduce
function, etc, etc... until the 'coll' is exhausted and the final result of 4
is returned as the quantity of items in the initial coll
(`[1 4.0 :foo "bar"]`)
I hope that actually makes sense when you read it 🙂
@yogidevbear that is correct 🙂
Thank you
how to rewrite the above example using #( ) form?
because #() requires that all the args to the anon fn are used at least once in the body
@bronsa thank you!
oh, I didn't expect it to work like that. Having said that, how could it work any other way?
well the alternative would be to make all anon fns variadic and ignore the remaining args, but eugh
What is the best way to debug a StackOverflow? I can see the stacktrace, but can't tell where it starts (The out put I get is all in clojure-1.8.0.ar code)
@bronsa yeah, I basically thought it did it variadically. But then I realised it must have to parse to figure out used variables in order to handle extra args. I mean cljs lets you do that I guess...
I found out about it because a colleague was on here. I've been on the standard clojure/beginners etc channels for a while
Eh, fair enough. I just wouldn't have figured we needed our own section over the base #clojure one. Still, I also idle in the IRC channel and that's got like 5-10 people in it who actually ever talk 😉
@carr0t we do talk Clojure from time to time... but most other subjects are fine as well.
the only "rule" we have is documented here: http://www.total-knowledge.com/~ilya/mips/ugt.html
morning
morning @danieleneal
Actually the time difference seems like a pragmatic reason to have this channel (or even a clojure-eu if we wanted to have our own little anti-brexit). We can be helping each other solve problems before the yankees[1] have had their coffee 😉 [1]: I say this as someone who married one so I mean no disrespect