Intro to Haskell Flashcards

1
Q

what is qsorts type? (in Haskell and in layman’s terms)

A

qsort :: Ord a => [a] -> [a]

for any type a of ordered values, qsort maps a list of such values to another.

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

what is the universal type in fp?

A

lists

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

describe the tail function in fp

A

tail[1, 2, 3]

[2, 3]

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

describe the !! function in fp

A

[1, 2, 3, 4] !! 2

3

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

describe the take function in fp

A

take 3 [1, 2, 3, 4, 5]

[1, 2, 3]

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

describe the drop function in fp

A

drop 3 [1, 2, 3, 4, 5]

[4, 5]

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

describe the length function in fp

A

length [1, 2, 3, 4]

4

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

describe the sum function in fp

A

sum [1, 2, 3, 4, 5]

15

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

describe the product function in fp

A

product [1 .. 5]

120

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

describe the ++ function in fp

A

[1, 2] ++ [3, 4]

[1, 2, 3, 4]

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

describe the reverse function in fp

A

reverse[1, 2, 3]

[3, 2, 1]

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

what is the highest priority in Haskell?

A

function application

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

what suffic do Haskell files use?

A

.hs

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

how would you write an infinite list?

A

[1 ..]

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

what is the naming convention for functions and arguments?

A

they must begin with a lower case character

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

what is the naming convention for lists?

A

they must end in s

17
Q

what is the naming convention for types?

A

they must begin with an upper case character.