- #1
whitehorsey
- 192
- 0
Adds one to a list of integers.
plusOne :: [Integer] -> [Integer]
plusOne = map (+ 1)
I'm having a hard time understanding how this function works. More specifically how recursion happens. Map takes a function and a list and applies that function to every element in the list. In this function, map doesn't seem to be taking a function it just has (+1) but it adds one to the whole list. How does this work?
plusOne :: [Integer] -> [Integer]
plusOne = map (+ 1)
I'm having a hard time understanding how this function works. More specifically how recursion happens. Map takes a function and a list and applies that function to every element in the list. In this function, map doesn't seem to be taking a function it just has (+1) but it adds one to the whole list. How does this work?