Skip to content

Instantly share code, notes, and snippets.

@gofer
Created December 7, 2013 14:38
Show Gist options
  • Save gofer/7843026 to your computer and use it in GitHub Desktop.
Save gofer/7843026 to your computer and use it in GitHub Desktop.
Print list
(* List print for debug *)
fun print_list nil = print "nil\n"
| print_list (x::xs) =
let
fun print_list_ nil = "nil"
| print_list_ (x::nil) = String.concat([(Int.toString(x)), "\n"])
| print_list_ (x::xs) = String.concat([Int.toString x, ", ", print_list_ xs])
in
print (print_list_ (x::xs))
end;
print_list nil;
(*
nil
val it = () : unit
*)
print_list [1, 2, 3, 4, 5];
(*
1, 2, 3, 4, 5
val it = () : unit
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment