Question: 1. Which tuples have the type? int * (bool * int) a. (3, 4) b. (7, (true, 9)) c. (false, 8) d. (5, (false, 8))

1. Which tuples have the type?

int * (bool * int) a. (3, 4)

b. (7, (true, 9))

c. (false, 8)

d. (5, (false, 8))

e. (true, 5)

f. (5, false)

g. (9, 5)

h. (7, true, 9, 5)

I. (7, true)

j. (8, 3, 4)

2. What value is bound to ans after the following ML code is evaluated?

fun mystery(x:int option, y:bool option) =

if isSome y andalso valOf y

then if isSome x

then let val z = (valOf x) in z * z end

else 0

else if isSome x

then ~(valOf x)

else ~1

val ans = mystery(NONE, SOME false)

3. Given this ML list:

val e = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]

What is the value of

[5] :: (tl e)

4. Given this ML tuple:

val e = (7, (true, 9), (5, false), 8, (3, 4)) What is the value of

#1 e

5. Given this ML list:

val e = [[0, 1], [2, 3, 4], [5, 6, 7, 8]] What is the value of:

tl e

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!