Skip to content

Latest commit

 

History

History
45 lines (24 loc) · 1.06 KB

exercise-1.md

File metadata and controls

45 lines (24 loc) · 1.06 KB

In the following expressions, identify the next expression to be evaluated and its continuation by marking the former with [ · ]. What is the type of the former? Given a value of this type, what is the type of the value returned by the continuation?

  1. 5 * (2 * 3 + 3 * 4)

    next expression: 2 * 3

    continuation: 5 * ([.] + 3 * 4)

    next expression type: int

    continuation type: int -> int_

  2. (if 2 = 3 then "hello" else "hi") ^ " world"

    next expression: (2 = 3)

    continuation: (if [.] then "hello" else "hi") ^ " world"

    next expression type: boolean

    continuation type: boolean -> string

  3. fst (let x = 1 + 2 in (x, x))

    next expression: (1 + 2)

    continuation: fst (let x = [.] in (x,x))

    next expression type: boolean

    continuation type: boolean -> string

  4. string_length ("x" ^ string_of_int (3 + 1))

    next expression: (3 + 1)

    continuation: string_length ("X" ^ string_of_int [.])

    next expression type: int

    continuation type: int -> int