3. Types and classes Flashcards

1
Q

How are chars and string stored?

A

char: ‘a’
string: “ask”

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

What is a curried function and give an example of one.

A

A function that uses the fact that we can return functions.
mult :: Int -> (Int -> (Int -> Int))
mult x y z = x * y * z

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

What are polymorphic types?

A

A type that can be many types.
i.e. [a] or b

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

What are class constraints and what is the syntax?

A

specifies the type.
C a where C is the name of the constraint and a is a type of variable.
i.e. (+) :: Num a => a -> a -> a

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

How to check inequality?

A

(/=) :: a -> a -> Bool

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

How to get the negative of a number?

A

negate :: a -> a

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

How do we get the sign of a number?

A

signum :: a -> a

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

How to divide two numbers?

A

> 7 div 2
3

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

How to get the modulo of a fraction?

A

> 7 mod 2
1

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