Question: Consider the following ML expressions. Evaluate each expression and write down its value followed by : and its type. For example the value of [

Consider the following ML expressions. Evaluate each expression and write down its value followed by :
and its type. For example the value of [1]::nil::nil is [[1],[]]:int list list. Another example,
nil::nil is [[]]:a list list. If the expression is invalid or will cause an error, explain why.
1.1::2::3::[4,5]
2. #2(1::2::3::[4,5])
3. #1(1::2::nil, "a", #"a")
4.[]@[[]]
5.[nil]::[[1]]
6.[nil]::[[]]
7. hd (tl [1,2,3]))
The following three expressions are function definitions. You are asked to infer the type of each function.
1. fun f x = hd x
2. fun f x = hd x +1
3. fun f x = hd x :: x

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 Programming Questions!