Comment

Comment by Saavedro

map 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]

parent Saavedro 11 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton