functional programming Flashcards
1
Q
what is functional programming?
A
- places emphasis on values
- computation is done by the evaluation of expressions
- emphasize mathematics, not storage
- values cannot be stored (no assignment)
- ML and Scheme
2
Q
expressions
A
- simple exprs are mathematical exprs
* conditionals are exprs (no if-then, only if-then-else)
3
Q
local declarations (let)
A
- allow names to be used in exprs
* decls are either value-binding or function-binding
3
Q
let bindings
A
- not assignment, shorthand
- can expand a binding in the code
- this expansion will not change meaning (no side effects)
- assignment/output statements change the state of the machine
4
Q
what is a type?
A
- a set of values together with operations on those values
* use type exprs to build new types
5
Q
type expressions can be:
A
1) a name
2) the product of two TEs
3) a list of TE
4) a mapping from one TE to another
6
Q
what defines basic types?
A
- values are atomic (cannot be broken down further)
- e.g. boolean, int, real
- only common operations: =,
7
Q
what is a list?
A
a finite sequence of elements (like arrays)
8
Q
what is a function?
A
- a mapping from a domain to a range (A->B)
- application is left associative
- way of writing parameterized expressions
9
Q
arguments
A
- functions take only a single argument in ML
* parameter list is expressed as a product
10
Q
recursion
A
a function that calls itself (directly or indirectly)