Skip to content

Instantly share code, notes, and snippets.

@colm-mchugh
Created May 10, 2017 03:56
Show Gist options
  • Save colm-mchugh/2ba54d80dece7c8256e246eb090c0aea to your computer and use it in GitHub Desktop.
Save colm-mchugh/2ba54d80dece7c8256e246eb090c0aea to your computer and use it in GitHub Desktop.
plemm questionnaire - ML
(** Question 1 **)
fun f1() =
(d = 32; g())
fun g() =
d + 3
f1()
(** Question 2 **)
fun f2(v) = if v then "blue" else "red";
f2(true)
f2(0)
f2("")
f2(1/0)
f2("0")
f2("-1")
f2(10)
**)
(* Question 3 *)
val f3 = fn y => y * b
val b = 10
f3(3)
(* Question 4 *)
val x = 0;
val f4 = fn y => let val x = 5 in y = x end;
val a = 9;
f4(a);
val result = a + x;
(* Question 5 *)
fun make_lambda() =
let val h = 2 in
fn x => x - h
end;
val h = 13;
val f5 = make_lambda();
val result = f5(20);
@niaiwomattt
Copy link

完成什么功能 ?看着实现方式很不好!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment