Higher-order functions: Difference between revisions

Content deleted Content added
→‎[[Ada]]: Added a more complex example
Added Clean example
Line 209:
return 0;
}
 
==[[Clean]]==
[[Category:Clean]]
 
Take a function as an argument and apply it to all elements in a list:
map f [x:xs] = [f x:map f xs]
map f [] = []
Pass a function as an argument:
incr x = x + 1
Start = map incr [1..10]
Do the same using a anonymous function:
Start = map (\x -> x + 1) [1..10]
Do the same using currying:
Start = map ((+) 1) [1..10]
 
==[[Haskell]]==