beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
R.A. Porter 2021-03-28T00:01:40.219100Z

I usually mutter under my breath and then use as->

walterl 2021-03-28T00:02:41.219300Z

For cases where the threaded values somewhere in the middle of the args, yeah

seancorfield 2021-03-28T02:28:04.219600Z

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).

🎉 3
zackteo 2021-03-28T10:37:02.222200Z

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

Mno 2021-03-28T10:45:42.222500Z

Map can take multiple seqs from which it takes an element of each sequence and passes it to the function

Mno 2021-03-28T10:48:17.222600Z

You could do: (map list [1 2 3] [4 5 6]) and get ((1 4)(2 5)(3 6))

Mno 2021-03-28T10:49:29.222700Z

In the first iteration it takes 1 and 4 and passes it to list so it would end up (list 1 4)

Mno 2021-03-28T10:51:59.222800Z

Or to give another example you can do (apply map + [[1 2] [3 4]) and get ((+ 1 3) (+ 2 4)) and then (4 6)

zackteo 2021-03-28T10:57:42.223400Z

Got it! Thank you!!

Mno 2021-03-28T12:00:22.223500Z

My pleasure 🙂

sova-soars-the-sora 2021-03-28T23:13:11.230800Z

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 ...

dpsutton 2021-03-28T23:22:59.231800Z

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

sova-soars-the-sora 2021-03-28T23:28:28.232100Z

oh I see. like (drop 50 (take 50 coll))

sova-soars-the-sora 2021-03-28T23:28:38.232300Z

or maybe I did that backwards...

sova-soars-the-sora 2021-03-28T23:28:53.232600Z

(take 50 (drop 50 coll))

sova-soars-the-sora 2021-03-28T23:29:09.232900Z

linear performance is probably Ok.