Reputation: 1
fun add nil = nil
| add ((a ,b) :: c) = (a+b) :: (add c);
I've just started learning SML, and the map function is new to me.
How can I use a map function in SML to implement this code?
Upvotes: 0
Views: 192
Reputation: 1153
-val a = [(1, 2), (2, 3), (3, 4)];
val a = [(1,2),(2,3),(3,4)] : (int * int) list
- map (fn (x, y) => x + y) a;
val it = [3,5,7] : int list
Upvotes: 2