Mind map
Syntax in Functions
Map content
Syntax in Functions
Pattern matching
- when writing functions
- you define separate function bodies for different patterns
- checked from top to bottom
- First: to specify the most specific ones first
- After: the more general ones
- Wanna avoid crashes??
- Include a catch-all pattern
- Some uses
- Tuples
- List comprehensions
- Lists
- x:xs
- x -> head
- xs:tail
- x:xs
- Using @
- xs@(x:y:ys)
- Patterns
- to which some data should conform
- when writing functions
Guards
- like IF, ELSE
- Some property of a value is?
- True
- False
- Some property of a value is?
- Not = after the function
- like IF, ELSE
Where
- Avoid repetitions of code
- Always after guards
- Bind to names or functions
Let
- Expressions
- Bind to variables at the end of a function
- More than one variable?
- separate by ;
- More than one variable?
- Bind to variables at the end of a function
- Sintaxis
- let <bindings> in <expression>
- Expressions
Case expressions
- like switch-case in java
- Similar to:
- pattern matching on parameters in function definitions
- Sintaxis
- case expression of pattern -> result
- expression is matched against the patterns.
- case expression of pattern -> result
Information
- Description
- Informática Mind Map on Syntax in Functions, created by Diego Alvarez on 27/02/2018.
- Created by
- Diego Alvarez
- Views
- 1
- Rating