ML Notes


Things to try..

(* type inference *)

fun zz x  = x / 2 ;
fun zz x y = x / y ;

fun zz x  = x div 2 ;
fun zz x y = x div y ;

(* bindings *)

val x = 5;
fun wow z = z + x;
wow 9;
val x = 10;
wow 9;

(* lazy vs. eager *)

fun looper x = looper(x):int;
fun heaper x = x*looper(x):int;

fun doit (flag,arg,func) =
   if flag
      then func(arg):int
      else 1
   ;

doit(true,5,heaper);
doit(false,5,heaper);

fun do2 (flag,arg) =
   if flag then arg else 1;

do2(true,heaper(5));
do2(false,heaper(5));