4 ms·
It returns the multiply-by-2 function. This turns out to be super useful map (* 2) [1, 2, 3] will take that function and apply it to each element in the lis
by spion 12y ago
It returns the multiply-by-2 function. This turns out to be super useful
map (* 2) [1, 2, 3]
will take that function and apply it to each element in the list [1,2,3].
- pbhjpbhj 12y agoThat map function looks a lot like it has 2 arguments, a function and an operand array (ie a list)??
- Saavedro 12y agomap takes a function and returns a function that takes a list and returns a list. It has a type like: (a->b) -> [a] -> [b] (I take a function from type a to type b and return a function from list of a to list of b) define double_list_elements = map (*2) and > double_list_elements [1, 2, 3, 4] gives you [2, 4, 6, 8]
- Sniffnoy 12y agoAgain, it works the same way. The map function takes the argument (*2) and returns a function, which is then applied to the list.
- pbhjpbhj 12y agoSeems like a semantic gloss, but then at some level I suppose higher level computing languages are all a semantic gloss. Thanks for the responses - I'm now almost as knowledgeable as a 10 yo prior to being instructed in the subject at hand.