English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2002-09-09 (23:09)
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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners