1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-07-31 20:10:49 +02:00

Merge pull request #74 from brunal/patch-1

Make myMap work on empty lists
This commit is contained in:
Adam Bard
2013-07-01 08:43:11 -07:00

View File

@@ -155,7 +155,7 @@ foo (x, y) = (x + 1, y + 2)
-- Pattern matching on arrays. Here `x` is the first element
-- in the array, and `xs` is the rest of the array. We can write
-- our own map function:
myMap func [x] = [func x]
myMap func [] = []
myMap func (x:xs) = func x:(myMap func xs)
-- Anonymous functions are created with a backslash followed by