Map

List.map applies a provided function to all elements of a list.

Example

( List.map negate [1, 2, -3] ) == [-1, -2, 3]
( List.map abs [1, 2, -3] ) == [1, 2, 3]

Problems to solve using List.map

Problem 4 - Count the elements using map. Hint: after passing a simple function to map, you can get the count by calling List.sum.

Problem 10 - Convert a list of lists to a list of lengths.

ConcatMap

List.concatMap applies a function that returns a list to the elments of a list, then concatenates the resulting list of lists into a single list.

Problem 14 - Duplicate each element of a list.

Problem 15 - Repeat elements of a list.

Problem 7 - Flatten nested lists.

Problem 12 - Decode a run-length encoded list.

Problem 72 - Collect the nodes of a multiway tree into a list.

results matching ""

    No results matching ""