CS152
Chris Pollett
Apr. 15, 2009
(define the-continuation #f) (define (test) (let ((i 0)) (call/cc (lambda (env) (set! the-continuation env))) (set! i (+ i 1)) i)) > (test) 1 > (the-continuation) 2 > (the-continuation) 3
smlThis gets you into interactive mode. The prompt will look like a hyphen. To get out of ML type CTRL-d.
use "myfile.sml";
1+2*3; val it = 7; int
fun fact n = if n = 0 then 1 else n * fact(n - 1);
val fact = fn : int -> int
fun fact (n: int): int = if n =0 then 1 else n*fact(n -1);To use our function we can type fact 5;