type Temperature = F of int | C of int
Console.WriteLine("A union: {0}", freezing)
printfn "A union: %A" freezing
let rows = [ (1,"a"); (-22,"bb"); (333,"ccc"); (-4444,"dddd") ]
printfn "==========================="
printfn "no alignment: |%i|%s|" i s
printfn "==========================="
printfn " wih alignment: |%5i|%5s|" i s
printfn "==========================="
printfn "with left align for column 2: |%5i|%-5s|" i s
printfn "==========================="
printfn "with dynamic column width 20 for col1: |%*i|%-5s|" 20 i s
printfn "==========================="
printfn "with dynamic col width for col 1 & col 2: |%*i|%-*s|" 20 i 10 s
printfn "==========================="
printfn "float: %f \nexponent: %e \ncompact: %g" pi pi pi
printfn "==========================="
let petabyte = pown 2.0 50
printfn "float: %f \nexponent: %e \ncompact: %g" petabyte petabyte petabyte
fun (tw:TextWriter) -> tw.Write(rand.Next(1,10))
printfn "rand = %t" printRand
let printLatLong (tw:TextWriter) (lat,long) =
tw.Write("lat:{0} long:{1}", lat, long)
let latLongs = [ (1,2); (3,4); (5,6)]
for latLong in latLongs do
printfn "latLong = %a" printLatLong latLong
let yymmdd1 (date:DateTime) = date.ToString("yy.MM.dd")
let yymmdd2 (tw:TextWriter) (date:DateTime) = tw.Write("{0:yy.MM.dd}", date)
let date = DateTime.Now.AddDays(float i)
printfn "using ToString = %s" (yymmdd1 date)
printfn "using a callback = %a" yymmdd2 date