Open shaunlebron opened 7 years ago
Good start: http://clojuredocs.org/quickref and http://cljs.info/cheatsheet/
It would also be nice to add a meta that differentiate the evaluation, whether it's strict or lazy. Could be simply called :evaluation with values #{:strict :lazy}.
like the difference between map
/filter
and mapv
/filterv
? I think most things generate lazy sequences, can you list the ones that you know are "strict"?
Sincerely no idea, I actually counted on your knowledge to enlighten me ;)
To be honest, all data literals (and equivalent API) are strict. We stumbled upon this fact when comparing the following :
(->> (range 10)
(map #(do (println "map") (inc %)))
(filter #(do (println "filter") (odd? %)))
(take 3)
println)
;; All lazy, will print 3 "map filter" then the result
(->> [1 2 3 4 5]
(map #(do (println "map") (inc %)))
(filter #(do (println "filter") (odd? %)))
(take 3)
println)
;; Strict, will first print 3 "map" then 3 "filter" then the result
So in a sense some API of Clojure(Script) are strict. It's not a completely lazy language like Haskell. Only the sequence API is lazy I suppose, but I don't know in details.
Maybe worth investigating and documenting ?
On Jul 27, 2017 15:11, "Shaun Lebron" notifications@github.com wrote:
like the difference between map/filter and mapv/filterv? I think most things generate lazy sequences, can you list the ones that you know are "strict"?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cljs/site/issues/11#issuecomment-318357284, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEt3s3GQnAax5gIkdEW_2ykHQkq4KV9ks5sSIx2gaJpZM4JlSIS .
(written from a phone, sorry for bad indentation and possible typos)
Yeah, in that case, I think it's good to categorize just the "strict" ones. Like doall
, filterv
, mapv
, and maybe even doseq
and run!
, and others we can try to find.
I think this official page can start as a good guide to find more : https://clojure.org/reference/lazy
Not sure that "only strict" will suffice. For my part I need to read and test more to truly understand where the distinction lies.
On Jul 27, 2017 21:56, "Shaun Lebron" notifications@github.com wrote:
Yeah, in that case, I think it's good to categorize just the "strict" ones. Like doall, filterv, mapv, and maybe even doseq and run!, and others we can try to find.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cljs/site/issues/11#issuecomment-318469117, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEt3jFIqkDJmkiwqohVJWIkbVMQoZITks5sSOtUgaJpZM4JlSIS .
Core is such a mish-mash that it needs categories to make it traversable.