(* * * * * * * * * * * * Resource Aware ML * * * * * * * * * * * * * * * * Use Cases * * * * File: * example/list_map.raml * * Author: * Jan Hoffmann, Shu-Chun Weng (2014) * * Description: * Some variations of list map. * *) (* The usual list map function. *) let rec map f l = match l with | [] -> [] | x::xs -> let ys = map f xs in (f x)::ys (* The usual list rev_map function. *) let map_rev f l = let rec rmap l acc = match l with | [] -> acc | x::xs -> let acc' = (f x)::acc in rmap xs acc' in rmap l [] let _ = let f x = let _ = Raml.tick 1.0 in x*x*x in let g x = x+2 in let h x = x in map h (map_rev h [2;3;4;4;5;5;5])