Skip to content

Instantly share code, notes, and snippets.

@cls cls/mk_idmap.sml

Last active Apr 9, 2018
What would you like to do?
Higher-order relabelling function, ported from OCaml to Standard ML
exception NotFound
fun mk_idmap (mk_id : unit -> 'b) : ''a list -> ''a -> 'b =
(fn (x, acc) =>
let val new_id = mk_id () in
fn id => if id = x then new_id else acc id
(fn _ => raise NotFound)
val mk_id : unit -> int =
let val id = ref 0 in
fn () => (id := !id + 1; !id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.