Mindmap
secondPart_<The syntax of functions>
Inhalt der Mindmap
secondPart_<The syntax of functions>
pattern matching
- We can separate the body that defines the behavior of a function in several parts
- lucky :: (Integral a) => a -> String lucky 7 = "¡El siete de la suerte!" lucky x = "Lo siento, ¡no es tu día de suerte!"
- if
- We can separate the body that defines the behavior of a function in several parts
_
- Intencional list
x:xs
- Recursive functions
patterns
- @
- capital :: String -> String capital "" = "¡Una cadena vacía!" capital all@(x:_) = "La primera letra de " ++ all ++ " es " ++ [x]
- we cant use
- (xs ++ ys)
- @
guards
- the guards are a way to check if any property of a value (or several of them) is true or false
- The guards are indicated with vertical bars that follow the name of the function and its parameters. They usually have a sangria and are aligned
- A guard is basically a Boolean expression. If True is evaluated, then the body of the corresponding function is used
Let it be
- Let
- they serve to link variables anywhere and are expressions in themselves
- where
- they are a syntactic construction that lets you link variables at the end of a function so that the whole function can access it
- Let
case
- It is very similar to other programming languages
Informationen
- Beschreibung
- Mindmap am secondPart_<The syntax of functions>, erstellt von Nicolas Acosta am 26/02/2018.
- Erstellt von
- Nicolas Acosta
- Aufrufe
- 0
- Bewertung