week 1 Flashcards

1
Q

Briefly describe the imperative programming paradigm

A

memory + assignment + control structures

how

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

Briefly describe the functional programming paradigm

A
function application
(How)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give the definition of add 1, using lambda calculus

A
add_one(x) = \x.(x+1)
add_one(3) = (\x.(x+1))(3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what does pure mean in programming paradigms?

A

no side effects

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

how do side effects occur?

A

via assignments (state changes) and many imperative structures

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

Define polymorphic types

A

functions with a generic type

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

describe type inference

A

no type annotation, the computer can work out the type statically at compile time

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

write the quicksort algorithm in Haskell

A

qsort[] = []
qsort(x : xs) =qsort smaller ++ [x] ++ qsort larger
where
smaller = [ a | a x]

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

describe functional programming in a restricted sense

A

programming without mutable variables, assignments, loops and other imperative control structures

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

what is a function in functional programming?

A

values that are produced, consumed, and composed

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

when we say imperative programming focuses on WHAT, what is the WHAT?

A

describing inputs, outputs, and the I/O relationships

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