I usually mutter under my breath and then use as->
For cases where the threaded values somewhere in the middle of the args, yeah
If the form should go in the last position, ->>
in a ->
pipeline is the “correct” thing. It the form should go elsewhere, then as->
might be right. But: https://stuartsierra.com/2018/07/06/threading-with-style (and read all his other do’s and don’ts).
Hello! Could someone explain to how I should think about (apply map ....)
I understand apply
and map
but don't quite understand how something like (apply map list
((0 1 2) (3 4 5) (6 7 8))`
;; => ((0 3 6) (1 4 7) (2 5 8)) works
Map can take multiple seqs from which it takes an element of each sequence and passes it to the function
You could do: (map list [1 2 3] [4 5 6])
and get ((1 4)(2 5)(3 6))
In the first iteration it takes 1 and 4 and passes it to list so it would end up (list 1 4)
Or to give another example you can do (apply map + [[1 2] [3 4])
and get ((+ 1 3) (+ 2 4))
and then (4 6)
Got it! Thank you!!
My pleasure 🙂
any tips on making paginated links ?
example: collection of 500 maps each with a timestamp.
show first 50 elements on page 1
page 1: 0-50, page2: 51-100... page 3: 101-150... etc
and have 10 clickable "page" buttons to go between them
is there take
for specific ranges in a sequence? I notice there is subvec
...
this is normally done with some implicit page size and a way to efficiently skip items in the collection. if you're just using a clojure datastructure, skip and take can get this with obviously linear performance
oh I see. like (drop 50 (take 50 coll))
or maybe I did that backwards...
(take 50 (drop 50 coll))
linear performance is probably Ok.