Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Does this function exist?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] Does this function exist?
> OK, so I want just "[3; 3]", (no type information),
> I can use printf, but it isn't very easy to write when you have i.e.
> list of pairs of lists. And i believe that there is unversal ``print''.
> Can you help?

You still can use the (undocumented because unsafe) Obj module of the
standard distribution. This enable you to recursivly scan ocaml blocks :

let rec print_ints x =
    let r = Obj.repr x in
    match Obj.is_int r with
    | true -> Printf.sprintf "%d" (Obj.magic x : int)
    | false -> (* recursivly print fields from 0 to (Obj.size r)-1 *) ...

val print_ints : 'a -> unit

Nicolas Cannasse

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: