wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Module 09 - Day 3

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the main concept of the mapping idiom?

a)

It changes the data type of the list.

b)

It applies a transformation to every list element.

c)

It sorts the list in ascending order.

d)

It removes duplicates from the list.

2.

What is the purpose of introducing an auxiliary parameter in my-map?

a)

To simplify the code

b)

To abstract the desired transformation

c)

To increase execution speed

d)

To reduce memory usage

3.

Which of the following patterns represents the map function: (map f (list x1 x2 ... xn))

a)

⇒ (list (f x1) (f x2) ... (f xn))

b)

⇒ (list x1 x2 ... xn)

c)

⇒ (f (list x1 x2 ... xn))

d)

⇒ (list x1 x2 ... xn f)

4.

What function captures the specialized pattern of mapping from natural numbers: 0, 1, 2 ... n-1?

a)

map-list

b)

build-list

c)

create-list

d)

generate-list

5.

What is the purpose of asking the caller to provide a base value in the context of abstract folding?

a)

To simplify the code

b)

To ensure the function always returns a list

c)

To handle unknown base values in any given context

d)

To make the function faster

6.

Which built-in function works just like my-fold?

a)

map

b)

filter

c)

foldr

d)

fold

7.

What purpose does the auxiliary parameter combine serve in foldr?

a)

The combine parameter indicates the maximum depth of the fold operation.

b)

The combine parameter is used to specify the data type of the input list.

c)

The combine parameter determines the base case for foldr.

d)

The combine parameter specifies how to combine the list element with the recursive result.

8.

Which of the following expressions is equivalent to (foldr cons empty (list 1 2 3))?

a)

(list (list 1 2 3))

b)

(list empty 1 2 3)

c)

(list 1 2 3)

d)

Error: cons cannot be used

9.

Given the expression (foldr - 0 (list 1 2 3)), what is the result?

a)

-4

b)

-2

c)

2

d)

0

10.

What is the result of the code?

a)

(list 1 4 9 16 25 36)

b)

(list 25 36 1 4 9 16)

c)

(list 25 36 16 9 4 1)

d)

(list (list 1 4 9 16) (list 25 36))

e)

Error