tags:

views:

89

answers:

2

I'd like to know if all formatting rules of printf functions currently work (or are implemented) in F# ?

For instance, if I want to align arguments on 9 characters (padding with spaces or 0), I would use:

printfn "%9A %9A" arg1 arg2 //don't seem to work

Thanks!

+1  A: 

Read the documentation:

http://msdn.microsoft.com/en-us/library/ee370560.aspx

Bertrand Marron
It says *%A : Formats any value, printed with the default layout settings.*. So I guess there's no layout at all for %A type, right?
Stringer Bell
Did you try to use StringFormat<T> ?
demokritos
+2  A: 

Do check out the docs

http://msdn.microsoft.com/en-us/library/ee370560(v=VS.100).aspx

(and possibly also these

http://en.wikibooks.org/wiki/F_Sharp_Programming/Input_and_Output

http://blogs.msdn.com/dsyme/archive/2010/01/08/some-tips-and-tricks-for-formatting-data-in-f-interactive-and-a-in-sprintf-printf-fprintf.aspx

)

though I am unclear about the fine points of the spec and implementation, especially regarding the %A specifier, which does various magical things. I'll see what other info I can dig up right now...

Brian
Thanks Brian. It works with printf "%9s" any_to_string arg1... well the function which I can't find that replaces any_to_string..
Stringer Bell