Mapa mental
Higher order functions

Conteúdo do mapa
Higher order functions
The Haskell functions can take functions as parameters and return functions as return values.
Each function in Haskell officially takes only one parameter
Curried functions
- put a space between two things is simply the application of the function
- calling a function with very few parameters, we get a partially applied function
- Infix functions can also be partially applied through the use of "()" sections
- partial application
- alling functions with too few parameters
- we are creating new functions on the fly
- alling functions with too few parameters
Some higher-orderism is in order
- Functions can take functions as parameters and also return functions.
- zipWith
- Take a function and two lists as parameters and then join the two lists by applying the function between the corresponding elements
Functional programming uses higher order functions to abstract common patterns
Maps and filters
- map takes a function and a list and applies that function to each item in the list, producing a new list.
- filter
- a predicate is a function that says if something is true or not
- is a function that takes a predicate and a list and then returns the list of elements that satisfy the predicate
- There's no set rule for when to use map and filter versus using list comprehension
- a predicate is a function that says if something is true or not
Lambdas
- Lambdas son básicamente funciones anónimas que se utilizan porque necesitamos algunas funciones solo una vez.
- we make a lambda with the sole purpose of passing it to a higher order function.
- Like normal functions, lambdas can take any number of parameters
- Lambdas are usually surrounded by parentheses
Only folds and horses
- the folds are very useful functions for the encapsulation
- scanl and scanr are like foldl and foldr, they only inform all the intermediate states of the accumulator in list form.
- They are something like the map function, only that they reduce the list to some individual value.
- The functions foldl1 and foldr1 work much like foldl and foldr, only that it is not necessary to provide them with an explicit initial value.
- the folds are very useful functions for the encapsulation
Function application with $
- the $ function has the lowest precedence
- convenience so that we do not have to write so many parentheses
- sqrt (3 + 4 + 9) or sqrt $ 3 + 4 + 9
Function composition
- means that composing two functions produces a new function that, when called with a parameter, say, x is the equivalent of calling g with the parameter x and then calling f with that result.
- Note the type declaration. f must take as parameter a value that has the same type as the return value of g
Imagens e arquivos do mapa
Informações
- Descrição
- Mapa Mental sobre Higher order functions, criado por CASTILLO ZAMBRANO LUIS FELIPE em 18-02-2018.
- Criado por
- CASTILLO ZAMBRANO LUIS FELIPE
- Visualizações
- 1
- Avaliação






