12.2 Writing functional programs Flashcards
1
Q
What does the Map function do?
A
Takes a second function and applies it to a list of elements before returning the new list
2
Q
What does the filter function do?
A
Returns the elements of the list which adhere ti the condition given. It is IN rather than a filter OUT.
3
Q
What does the fold function do?
A
Reduce the list to a single value. Known as reducing. The function needs an operator (+,-) a starting number and a list. The type - left or right - determines how the recursion will work.