CS 541 quiz on functions as first class values * quiz (just for fun, not graded) Do one of the first two, and then some of the others if you finish early ** What is the the result of the following expression? let val m = (fn (x,y) => (fn f => f(x,y))); val a = (fn z => (z (fn (p,q) => p))); val r = (fn z => (z (fn (p,q) => q))); in let val x = 5 val y = 6 in a (r (m (3, m(1,2)))) end end; ** What is the the result of the following expression? (* sugared form of above *) let fun m (x,y) f = f(x,y); fun a z = (z (fn (p,q) => p)); fun r z = (z (fn (p,q) => q)); in let val x = 5 val y = 6 in a (r (m (3, m(1,2)))) end end ** What is the the result of the following expression? let fun T x y = x(); fun F x y = y(); fun I x y z = x y z; in let fun num x () = x in (I F (num 4) (num (I T (num 5) (num 6)))) end; end; ** What is the result of the following expression? let fun qr n d ret err = if d = 0 then err d else ret (n div d) (n mod d) in qr 2 3 (fn q => fn r => q + r) (fn x => 0) end;