Skip to content

Instantly share code, notes, and snippets.

@nishio
Created July 26, 2010 11:06
Show Gist options
  • Save nishio/490428 to your computer and use it in GitHub Desktop.
Save nishio/490428 to your computer and use it in GitHub Desktop.
let print x =
let tag = Obj.tag x in
if (tag == Obj.string_tag) then
Printf.printf "%s\n" (Obj.obj x)
else if(tag == Obj.int_tag) then
Printf.printf "%d\n" (Obj.obj x)
else if(tag == Obj.double_tag) then
Printf.printf "%f\n" (Obj.obj x)
else
Printf.printf "Unknown Type!\n"
;;
print (Obj.repr "hoge");;
print (Obj.repr 1);;
print (Obj.repr 1.5);;
print (Obj.repr [1;2;3]);;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment