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
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-04-23 (10:56)
From: Christian Sternagel <christian.sternagel@u...>
Subject: Format.printf
Is there a possibility to parametrize format-strings.
E.g. I want to provide a function [print_string], that,
given an integer [i], right-aligns a string as if it was 
of length [i]. But following code is obviously not

 let print_string i s = Format.printf "%%is\n" i s;;

Since "%%" is a `normal' %. But since I do not know the
needed length in advance I can not write something like

 let print_string i s = Format.printf "%10s\n" s;;

Any suggestions?