An Interest In:
Web News this Week
- March 22, 2024
- March 21, 2024
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
October 27, 2019 01:53 pm GMT
Original Link: https://dev.to/wakeupmh/taking-n-first-elements-from-a-list-in-clojure-13e8
Taking n first elements from a list in Clojure
Faster than a hadron collider
We have a list of orders and want to get the first 2 elements
How we can do that?
(def order [ {:id 15 :quantity 3 :price 5} {:id 3 :quantity 24 :price 1} {:id 7 :quantity 6 :price 9}])(println (take 2 order)) ;take [0, 1] from list of elements(println (nth order 2)) ;better than (get _ _) to get elements from a list
Thanks for your time
Original Link: https://dev.to/wakeupmh/taking-n-first-elements-from-a-list-in-clojure-13e8
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To