Mapa mental
starting out
Contenido del mapa
starting out
infix functions
- 5*5
- 5/5
- 5+5
- 5-5
- explicit precedence: ()
- function has the higher precedence
prefix functions
- as infix function
- 92 `div` 10
- calling
- name argument argument
- succ 8
- max 6.0 7.5
- min 5 6
- name argument argument
- creating
- functionName [parameters..] = <what the function does>
- doubleUs x y = x*2 + y*2
- doubleUs 4 9
- different version?
- doubleUs'
- No parameters?
- name || definition
- doubleUs x y = x*2 + y*2
- Is their order important in .hs file?
- No
- functionName [parameters..] = <what the function does>
- as infix function
boolean algebra
- &&
- ||
- not
- True
- False
in(equality)
- ==
- /=
expression
- a piece of code that returns a value
- like
- if statement
- if <condicion> then <..> else <..>
- else is mandatory
- so, makes the if an expression
- else is mandatory
- if <condicion> then <..> else <..>
- if statement
- like
- a piece of code that returns a value
List
- [1,2, 3]
- homogenous data structure
- Strings
- ['h', 'a', 's']
- [3,4,5]
- concatenation
- ++
- [1,2,3] ++ [4,5,6]
- ++
- add element at head ?
- 0 : [1,2,3]
- [0,1,2,3]
- 0 : [1,2,3]
- [[],[],[]]
- must be of equal type!!
- need at element?
- [] !! <index>
- are comparable in lexicographical order.
- [3,2,1] > [2,1,0]
- True
- [3,2,1] > [2,1,0]
- Ranges
- [1..5]
- ['a'..'z']
- with steps
- [2,4..20]
- [20,19..1].
- [13,26..24*13]
- works well with float-point?
- No, precision-lost
- Common functions
- head
- infinite?
- cycle
- repeat
- comprehensions
- [x*2 | x <- [1..10]
- with predicates || filtering
- [x*2 | x <- [1..10], x*2 >= 12]
- with predicates || filtering
- like in math
- S = {2X | x E N, x <= 10}
- [x*2 | x <- [1..10]
- of
- should be of equal size
- [(1,2),(8,11,5),(4,5)]
- Error!!
- [(1,2),(8,11,5),(4,5)]
- should be of equal size
Tuples
- pair
- (1,2)
- heterogenous data structure
- triple
- (1,"Two",3)
- some functions
- fst
- fst (1,2)
- 1
- fst (1,2)
- snd
- snd (1,2)
- 2
- snd (1,2)
- zip
- zip [1,2] [3,4]
- [(1,3), (2,4)]
- zip [1,2] [3,4]
- fst
- pair
Información
- Descripción
- Informática Mapa Mental sobre starting out, creado por Diego Alvarez el 27/02/2018.
- Creado por
- Diego Alvarez
- Visitas
- 1
- Valoración