Programming III Flashcards

1
Q

What are the distinct type operators in the below function definition?

A

(,) , -> , [] , Maybe

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

What are the distinct data constructors in the below function definition?

A

Nothing , Just , []

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

Higher Order Function

A

A function that takes a function as an argument, or returns a function.
Example: all curried functions

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

Curried function

A

A function that returns a function

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

curry and uncurry

A

curry: takes function that takes a single argument, and returns that function so that it takes multiple arguments.
uncurry: takes function that takes multiple arguments, and returns that function so that it takes a single argument.

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

Polymorphic function

A

A function is polymorphic if its type definition contains one or more unconstrained type variable

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

zip function

A

Appends two lists together, combining values from the same index into a pair.
If one list is shorter, it truncates the longer list.
zip: [a] -> [b] -> [(a,b)]

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

Alpha equivalent

A

Two terms are alpha equivalent if one can be converted to the other by alpha conversion.
* λ x -> λ y -> x y z is alpha equivalent to:
λ x -> λ w -> x w z
* λ x -> λ y -> x y z is not alpha equivalent to:
λ x -> λ z -> x z z

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

Redex

A

Reducible expression:
an expression comprising a function applied to an argument expression.

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

Innermost redex

A

A redex containing no other redexes

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

Outermost redex

A

A redex not contained in any other redex

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

Innermost evaluation

A

Innermost redexes are evaluated first

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

Outermost evaluation

A

Outermost redexes are evaluated first

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

Leftmost evaluation

A

Start with the leftmost redex

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

Rightmost evaluation

A

Start with the rightmost redex

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

Haskell evaluation strategy

A

Outmost, leftmost evaluation

Call-by-Name

17
Q

Call-by-Value reduction strategy

A

Leftmost, innermost reduction

18
Q

Call-by-Name evalution strategy

A

Leftmost, outermost evaluation

19
Q

Lambda calculus

Bound and Free variables

A

A variable is bound if given with a lambda symbol,
e.g. x is bound in λ x -> x y

A variable is otherwise free,
e.g. y is free in λ x -> x y

20
Q

Lambda calculus

Scope of a binding

A

Everything coming after the lambda definition of the variable,
e.g. e1 is the scope of x in λ x -> e1

21
Q

Lambda calculus

Scope of an abstraction

A

All values given with lambda symbols,
e.g. x is in the scope and y isn’t of λ x -> x y

22
Q

Lambda calculus

Closed term

A

A lambda calculus term with no free variables is closed

23
Q

Bind (>>=)

A

Takes a structured value and a function that may produce a structured result, and applies the latter to the former to produce a structured result:
>>= : (f a) -> (a -> f b) -> (f b)

24
Q

return

A

Takes a value of data type a, and returns the value as a Maybe data type, e.g. m a

25
Q

java.util.Stream

Intermediate operators

A
  • filter
  • peek
  • distinct
  • sorted
  • iterate
26
Q

java.util.Stream

Terminal operations

A
  • forEach
  • toArray
  • reduce (inc. max, min, count)
  • collect
27
Q

Isomorphism between two data types T and U

A

An isomorphism exists if there exists are a pair of functions taking T -> U and U -> T,
and T and U have an equal size

28
Q

Monad properties

A

Associativity and Distributivity