Well I think you have made a wise decision to learn Haskell, but it is really unlike any programming language you have probably learned until now.
Lets first review what id
and const
do.
The id
function is a function that doesn't change anything -- whatever you pass to it, the same value comes out unchanged. So id 5
equals 5
, id False
equals False
id "hello"
equals "hello"
, id ()
equals ()
.
The const
function is a function that always returns the same value, no matter what you give to it. const 5 True
equals 5
, const 5 "hello"
equals 5
, const 5 ()
equals 5
, no matter what, const 5
always returns 5
.
Now, do you understand what the map
and iterate
do? The map
function takes a list and a function and uses the function to modify each elements in the list with the function. For example: