CS152
Chris Pollett
Apr. 27, 2009
As we talk about the above we'll continue to introduce ML.
datatype ref_int = ref of int;
datatype 'label btree = Empty | Node of 'label * 'label btree * 'label btree;
datatype message = GetBalance | Withdraw of int; fun make_atm data GetBalance = !data:int | make_atm data (Withdraw x) = ( data := !data - x; !data) (* parentheses are like begin/end in Scheme *) val b = make_atm (ref 100); b GetMessage; b (Withdraw 10);
Which of the following pairs of types best illustrates the process of type currying?
1.0 * x/2 /* 2 is coerced to a float */ (char)65 /* the int 65 is explicitly converted to a char */
+ / \ [] i | \ a i