Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Missing tabs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi Vanicat <vanicat@l...>
Subject: Re: [Caml-list] Missing tabs
Richard Jones <rich@annexia.org> writes:

> $ ocaml
>         Objective Caml version 3.07+2
>
> # open Printf;;
> # List.iter (printf "\t%s\n") ["foo"; "bar"; "baz"; "buz"];;
>         foo
> bar
> baz
> buz
> - : unit = ()
> #
>
> Where did the second and subsequent tabs go? I even tried piping the
> output into the 'hd' shell command, and they are definitely missing.

printf is partially applied : when you do (printf "\t%s\n"), you print
a tab, and return a function that print its string argument and a new
line.

this will make what you want :

List.iter (fun x -> printf "\t%s\n" x) ["foo"; "bar"; "baz"; "buz"];;


-- 
Rémi Vanicat

-------------------
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