
Hi, I would like to get a string for a number using always 2 digits (i.e., 75 would be "75", 3 would became "03"). What is the best way to do that? I tried printf "%02d\n" 3 which gives me the correct string, but ghci always ends that call with a *** Exception: Prelude.undefined message. What else should I try? Can Text.PrettyPrint do that? Thanks, Maurício

briqueabraque:
Hi,
I would like to get a string for a number using always 2 digits (i.e., 75 would be "75", 3 would became "03"). What is the best way to do that? I tried
printf "%02d\n" 3
which gives me the correct string, but ghci always ends that call with a
*** Exception: Prelude.undefined
message. What else should I try? Can Text.PrettyPrint do that?
It's to do with ghci's defaulting. This is fixed in ghc 6.8: Prelude Text.Printf> printf "%02d\n" 3 03 You can work around it for now with: Prelude Text.Printf> printf "%02d\n" 3 >> return () 03 -- Don
participants (3)
-
Don Stewart
-
Maurício
-
Shachaf Ben-Kiki