apply and map in clojure
It is a very confusing comparison between map and apply.
1 | |
The famous function map means to call function provided to each element in collection once at a time.
1 | |
There are 3 elements in data, map calls println for each element.
Whereas appy just call function once, but extract all elements from collection before calling.
1 | |
Here only has 1 line of printing.
Some more experiments:
1 | |
Obviously, apply extracts elements from collection.
1 | |
apply and map in clojure
https://rug.al/2015/2015-04-26-apply-and-map-in-clojure/