Created
May 10, 2017 03:56
-
-
Save colm-mchugh/2ba54d80dece7c8256e246eb090c0aea to your computer and use it in GitHub Desktop.
plemm questionnaire - ML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
完成什么功能 ?看着实现方式很不好!