Please note that the Clojure map is a fairly flexible function, as it can do several things where you need different functions in other languages.
For example, it performs all three Haskell functions:
map :: (a -> b) -> [a] -> [b] zip :: [a] -> [b] -> [(a, b)] zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
Where
zip = zipWith (,)
So, in Clojure, you use map to do two different things:
a) Convert the sequence in order to a sequence of the same length. This is what is called a "map" in Haskell and other languages.
b) Replace two or more sequences together with one element, creating a sequence that reaches the shortest input sequence. This is called "zipWith" in Haskell.
The attached function should take as many parameters as there are input sequences, and returns the elements that should be included in the output sequence.
The code you specified uses map in the second function. It extracts 0 elements from (0 1 2 3) and 1 element from (1 2 3) . Results that (0 1 2 3) and (2 3) fall into the sequence of results.
source share