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