Functional Languages Flashcards

(22 cards)

1
Q

functional language purpose

A
  • general programming
  • symbolic programming
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

first class functions

A

function are values, they can be passed as arguments and returned from functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

datastructures

A

treated holistically rather than element by element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

functional features in mainstream languages

A
  • closures/anonymous functions/lambdas
  • first class functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

variable

A

a symbol or name that refer to a memory location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

expression

A

a combination of variables, operators, etc that describe a computation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

value

A

an instance of a datatype

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

parameters

A

the variables in the function definition

sometimes called formal parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

arguments

A

the values passed when calling a function

sometimes called actual parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

declaration

A

where we indicate a symbol is a variable, often also has a type declaration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

definition

A

the first time we give a variable a value

mostly refers to functions, initialisation used for non-functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

call by value

A

values of the argument expressions are passed into the function call

e.g. f(x+y, x-y) would pass the resuts of the expressions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

call by reference

A

a reference to a variable is passed rather than the value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

call by name

A

the expressions in the call are substituted into the function body and are then evalauted. they are passed in and then evaluated rather than evaluated and then passed in as in call by value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

call by need

A

like call by name that only evaluates a given argument once to get closer to the efficiency of call by value. this is done by memoising the argument evaluations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

laziness

A
  • used in many languages
  • called short circuit evaluation
  • often logical operators are lazy

e.g. if x = 0 then in (x == 0 || 1/x == 0) the 1/x == 0 is never evaluated because it won’t change the outcome of the condition, this is a useful feature as if x ==0 and 1/x is still evaluted then it will likely throw an error

17
Q

combinator

A

a higher order function

18
Q

program in combinatory logic

A

a variable-free composition of functions

19
Q

reduction

A

evaluating an expression by simplifying it according to formal rules

moves the data around inside the expression

20
Q

SKI combinators

A

all operations in lambda calculus can be encoded via abstraction elimination into the SKI calculus as binary trees whose leaves are one of the three symbols S, K, and I

21
Q

super combinators

A

program specific combinators are synthesised from the program itself, larger instructions and more efficient encoding

haskell is an example of this