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
programmatic access to toplevel print facilities
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sam Steingold <sds@p...>
Subject: programmatic access to toplevel print facilities
is there a way to access the top-level printing facilities from a program?

e.g., ocaml toploop will print a complex structure nicely:
# let x = make_my_huge_struct ();;
val x : my_huge_struct =
{a = 1; b = 2; c = 3; ...}

how do I access this from a program?
e.g., if I have an array of my_huge_struct, I want to be able to examine
a part of it:

let show_part arr p1 p2 =
  for i = p1 to p2 do
    ocaml_toploop_print (Array.get arr i)

# show_part array_of_huge_structs 100 105;;

(in lisp I would do
 (loop :for i :from p1 :to p2 :do (print (aref array_of_huge_structs i))))

Sam Steingold ( on Fedora Core release 5 (Bordeaux)
Your mouse has moved - WinNT has to be restarted for this to take effect.