#!/usr/bin/env swift; import Foundation import Utils // Begin Main let first:String = "First" let middle:String = "Middle" let lastname:String = "Last" let left:String = "Left" let center:String = "Center" let right:String = "Right" let favorite:String = "kerfuffle" let i1:Int64 = 3261963 let i2:Int16 = -42 let fp1:Double = 3.1415926 let fp2:Double = 2.99792458e9 let fp3:Double = -1.234e-4 var s:String = Utils.format("{2}, {0} {1}", first, middle, lastname) print(s) s = Utils.format("{0} {1} {2}", left, center, right) print(s) s = Utils.format("Favorite number is {0}", i1) print(s) s = Utils.format("Favorite FP is {0}", fp1) print(s) var c:Int = Utils.codepoint_at(favorite, 0) print(Utils.format("Favorite c is {0:c}", c)) print(Utils.format("Favorite 11c is |{0:11c}|", c)) print(Utils.format("Favorite <11c is |{0:<11c}|", c)) print(Utils.format("Favorite ^11c is |{0:^11c}|", c)) print(Utils.format("Favorite >11c is |{0:>11c}|", c)) print(Utils.format("Favorite .<11c is |{0:.<11c}|", c)) print(Utils.format("Favorite _^11c is |{0:_^11c}|", c)) print(Utils.format("Favorite >11c is |{0: >11c}|", c)) c = 0x1F92F print(Utils.format("Favorite emoji c is {0:c}", c)) print(Utils.format("Favorite s is {0:s}", favorite)) print(Utils.format("Favorite .2s is {0:.2s}", favorite)) print(Utils.format("Favorite 11s is |{0:11s}|", favorite)) print(Utils.format("Favorite 11.2s is |{0:11.2s}|", favorite)) print(Utils.format("Favorite <11.2s is |{0:<11.2s}|", favorite)) print(Utils.format("Favorite ^11.2s is |{0:^11.2s}|", favorite)) print(Utils.format("Favorite >11.2s is |{0:>11.2s}|", favorite)) print(Utils.format("Favorite .<11.2s is |{0:.<11.2s}|", favorite)) print(Utils.format("Favorite *^11.2s is |{0:*^11.2s}|", favorite)) print(Utils.format("Favorite ->11.2s is |{0:->11.2s}|", favorite)) print(Utils.format("Favorite d is {0:d}", i1)) print(Utils.format("Another d is {0:d}", i2)) print(Utils.format("Favorite b is {0:b}", i1)) print(Utils.format("Another B is {0:b}", i2)) print(Utils.format("Favorite o is {0:o}", i1)) print(Utils.format("Another o is {0:o}", i2)) print(Utils.format("Favorite x is {0:x}", i1)) print(Utils.format("Another X is {0:X}", i2)) print(Utils.format("Favorite #b is {0:#b}", i1)) print(Utils.format("Another #B is {0:#b}", i2)) print(Utils.format("Favorite #o is {0:#o}", i1)) print(Utils.format("Another #o is {0:#o}", i2)) print(Utils.format("Favorite #x is {0:#x}", i1)) print(Utils.format("Another #X is {0:#X}", i2)) print(Utils.format("Favorite 11d is |{0:11d}|", i1)) print(Utils.format("Favorite +11d is |{0:+11d}|", i1)) print(Utils.format("Favorite 011d is |{0:011d}|", i1)) print(Utils.format("Favorite 011x is |{0:011x}|", i1)) print(Utils.format("Favorite #011x is |{0:#011x}|", i1)) print(Utils.format("Favorite f is {0:f}", fp1)) print(Utils.format("Another f is {0:f}", fp2)) print(Utils.format("One more f is {0:f}", fp3)) print(Utils.format("Favorite e is {0:e}", fp1)) print(Utils.format("Another e is {0:e}", fp2)) print(Utils.format("One more e is {0:e}", fp3)) print(Utils.format("Favorite g is {0:g}", fp1)) print(Utils.format("Another g is {0:g}", fp2)) print(Utils.format("One more g is {0:g}", fp3)) print(Utils.format("Favorite .2f is {0:.2f}", fp1)) print(Utils.format("Another .2f is {0:.2f}", fp2)) print(Utils.format("One more .2f is {0:.2f}", fp3)) print(Utils.format("Favorite .2e is {0:.2e}", fp1)) print(Utils.format("Another .2e is {0:.2e}", fp2)) print(Utils.format("One more .2e is {0:.2e}", fp3)) print(Utils.format("Favorite .2g is {0:.2g}", fp1)) print(Utils.format("Another .2g is {0:.2g}", fp2)) print(Utils.format("One more .2g is {0:.2g}", fp3)) print(Utils.format("Favorite 15.2f is |{0:15.2f}|", fp1)) print(Utils.format("Another 15.2e is |{0:15.2e}|", fp2)) print(Utils.format("One more 15.2g is |{0:15.2g}|", fp3)) exit(EXIT_SUCCESS)