Haskell Flashcards

1
Q

Instead of the + symbol, Haskell uses the symbol ANSWER for a string concatenation operator
.

A

++

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

The type of a string constant in Haskell by default is written ANSWER.

A

[Char]

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

In Haskell, you use the keyword ANSWER to collect related code into a similar scope.

A

module

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

In Haskell, if I define a function double x = x + x its type signature would be ANSWER.

A

(Num a ) => a -> a

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

In Haskell, instead of writing something like if x ==0 then 1 else fact (x-1)*x, you can write a series of lines starting with factorial 0 = 1. This second style is called ANSWER.

A

pattern matching

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

In Haskell, instead of writing something like if x==0 then 1 else fact (x-1) x, you can write a series of lines starting with | x > 1 = x factorial (x-a). This second style is called ANSWER.

A

using guards

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

In Haskell, instead of writing something like second x = head(tail(x)), you can write this without introducing the parameter x by using function composition. Doing that, you would define second by ANSWER.

A

second = head . tail

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

In Haskell, if I write (h:t) = [3 , 5 ,7], ANSWER is the value of h.

A

3

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

In Haskell, if I write (h:t) = [3, 5, 7], ANSWER is the value of t.

A

[5,7]

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

In Haskell, ANSWER is the output of zip [17…20] [10 , 8 ….4].

A

[(17,10),(18,8),(19,6), (20,4)]

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

In Haskell, ANSWER is the output of zip [20….17] [10,8…4]

A

[]

Default increment is 1 and zip only goes as far as shortest argument list

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

In Haskell, the anonymous function ANSWER causes the expression ‘map ANSWER [1,2,3]’ to produce [-4, -5, -6].

A

(\x-> - (x+3))

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

In Haskell, if we want to define a local named function inside a function definition, we use the keyword ANSWER.

A

where

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

In Haskell, the type signature of the function sum x y = x + y is ANSWER.

A

(Num a ) => a -> a -> a

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

In Haskell, given the definition sum x y = x + y, ANSWER is the value of that is produced by the expression (sum 3).

A

(\x -> 3 + x)

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

The way Haskell handles functions with more than one parameter is called ANSWER.

A

currying

17
Q

In most languages, a function definition like f a b = a : (f (a + b) b) would result in an infinite recursion. However, in Haskell we can partially evaluate functions like this because Haskell is based on ANSWER.

A

lazy evaluation

18
Q

Although Haskell is a statically typed language, we usually don’t need to write type declarations because Haskell uses ANSWER to handle the matter.

A

type inference

19
Q

In Haskell, we can declare the type of a parameter to a function to be something specific like Num. However, we can also declare the type of a parameter to be something that could include many types like ListLike that supports the functions head and tail. We do this with a definition of ListLike that begins with the keyword ANSWER.

A

class

20
Q

One of the three most significant parts of a monad is called ANSWER, which wraps up a function and puts it in the container.

A

return

21
Q

One of the three most significant parts of a Haskell monad is called ANSWER, which unwraps up a function.

A

> > =

a bind function

22
Q

In Haskell’s do notation for working with monads, assignment uses the ANSWER operator.

A

(left arrow)

23
Q

Since Haskell doesn’t have traditional error handling mechanisms, by convention, people use the ANSWER monad to distinguish a valid return from an error return.

A

Maybe

This is similar to NaN’s usage in IEEE standard floating point arithmetic

24
Q

Haskell, defining lists using a notation like [x*2 | x (left arrow) [3,4,5]] is called using ANSWER.

A

list comprehesions

25
Q

In Haskell, [x*2 | x (left arrow) [3,4,5]] evaluates to ANSWER.

A

[6, 8, 10]