]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/formatting/formatting-docs.factor
use radix literals
[factor.git] / basis / formatting / formatting-docs.factor
old mode 100644 (file)
new mode 100755 (executable)
index 196302f..ede5d11
@@ -12,17 +12,19 @@ HELP: printf
     "specifying attributes for the result string, including such things as maximum width, "
     "padding, and decimals.\n"
     { $table
-        { "%%"      "Single %"                   "" }
-        { "%P.Ds"   "String format"              "string" }
-        { "%P.DS"   "String format uppercase"    "string" }
-        { "%c"      "Character format"           "char" } 
-        { "%C"      "Character format uppercase" "char" } 
-        { "%+Pd"    "Integer format"             "fixnum" }
-        { "%+P.De"  "Scientific notation"        "fixnum, float" }
-        { "%+P.DE"  "Scientific notation"        "fixnum, float" }
-        { "%+P.Df"  "Fixed format"               "fixnum, float" }
-        { "%+Px"    "Hexadecimal"                "hex" }
-        { "%+PX"    "Hexadecimal uppercase"      "hex" }
+        { "%%"          "Single %"                   "" }
+        { "%P.Ds"       "String format"              "string" }
+        { "%P.DS"       "String format uppercase"    "string" }
+        { "%c"          "Character format"           "char" } 
+        { "%C"          "Character format uppercase" "char" } 
+        { "%+Pd"        "Integer format"             "fixnum" }
+        { "%+P.De"      "Scientific notation"        "fixnum, float" }
+        { "%+P.DE"      "Scientific notation"        "fixnum, float" }
+        { "%+P.Df"      "Fixed format"               "fixnum, float" }
+        { "%+Px"        "Hexadecimal"                "hex" }
+        { "%+PX"        "Hexadecimal uppercase"      "hex" }
+        { "%[%?, %]"    "Sequence format"            "sequence" }
+        { "%[%?: %? %]" "Assocs format"              "assocs" }
     }
     $nl
     "A plus sign ('+') is used to optionally specify that the number should be "
@@ -34,7 +36,7 @@ HELP: printf
     "For example:\n"
     { $list
         "\"%5s\" formats a string padding with spaces up to 5 characters wide."
-        "\"%08d\" formats an integer padding with zeros up to 3 characters wide."
+        "\"%03d\" formats an integer padding with zeros up to 3 characters wide."
         "\"%'#5f\" formats a float padding with '#' up to 3 characters wide."
         "\"%-10d\" formats an integer to 10 characters wide and left-aligns." 
     }
@@ -43,7 +45,7 @@ HELP: printf
     "string. For example:\n"
     { $list 
         "\"%.3s\" formats a string to truncate at 3 characters (from the left)."
-        "\"%.10f\" formats a float to pad-right with zeros up to 10 digits beyond the decimal point."
+        "\"%.10f\" formats a float to pad-tail with zeros up to 10 digits beyond the decimal point."
         "\"%.5E\" formats a float into scientific notation with zeros up to 5 digits beyond the decimal point, but before the exponent."
     }
 }
@@ -54,16 +56,12 @@ HELP: printf
         "00123" }
     { $example
         "USING: formatting ;"
-        "HEX: ff \"%04X\" printf"
+        "0xff \"%04X\" printf"
         "00FF" }
     { $example
         "USING: formatting ;"
         "1.23456789 \"%.3f\" printf"
         "1.235" }
-    { $example 
-        "USING: formatting ;"
-        "1234567890 \"%.5e\" printf"
-        "1.23457e+09" }
     { $example
         "USING: formatting ;"
         "12 \"%'#4d\" printf"
@@ -72,6 +70,14 @@ HELP: printf
         "USING: formatting ;"
         "1234 \"%+d\" printf"
         "+1234" }
+    { $example
+        "USING: formatting ;"
+        "{ 1 2 3 } \"%[%d, %]\" printf"
+        "{ 1, 2, 3 }" }
+    { $example
+        "USING: formatting ;"
+        "H{ { 1 2 } { 3 4 } } \"%[%d: %d %]\" printf"
+        "{ 1:2, 3:4 }" }
 } ;
 
 HELP: sprintf
@@ -119,10 +125,11 @@ HELP: strftime
 
 ARTICLE: "formatting" "Formatted printing"
 "The " { $vocab-link "formatting" } " vocabulary is used for formatted printing."
-{ $subsection printf }
-{ $subsection sprintf }
-{ $subsection strftime }
-;
+{ $subsections
+    printf
+    sprintf
+    strftime
+} ;
 
 ABOUT: "formatting"