From 101c600945cad13eca8fb307992f0eb086e6652c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 11 Jun 2021 20:15:52 -0700 Subject: doc: add pic examples. * txr.1: Examples added. --- txr.1 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/txr.1 b/txr.1 index 8f07ae8f..2fb9845c 100644 --- a/txr.1 +++ b/txr.1 @@ -55052,6 +55052,43 @@ encodes a literal .code # character that is not part of any pattern. +.TP* Examples: + +.verb + ;; numeric formatting + (pic "######" 1234.1) -> " 1234" + (pic "######.#" 1234.1) -> " 1234.1" + (pic "#######.##" 1234.1) -> " 1234.10" + (pic "#######.##" -1234.1) -> " -1234.10" + (pic "0######.##" 1234.1) -> "0001234.10" + (pic "+######.##" 1234.1) -> " +1234.10" + (pic "-######.##" 1234.1) -> " 1234.10" + (pic "+0#####.##" 1234.1) -> "+001234.10" + (pic "-0#####.##" 1234.1) -> " 001234.10" + + ;; overflow with ! + (pic "#!#" 1234) -> "###" + (pic "#!#" 123) -> "###" + (pic "-##!#" -123) -> "#####" + (pic "+##!#" 123) -> "#####" + (pic "###!" 1234) -> "###" + + ;; alignment, multiple arguments + (pic "<<<<<< 0#.# >>>>>>>" "foo" (+ 2 2) "bar") + --> "foo 04.0 bar" + + ;; quasiliteral + (let ((a 2) (b "###") (c 13.5)) + (pic `abc@(+ a a)###.##@b>>>>` c "x")) + --> "abc4 13.50### x" + + ;; filename generation + (mapcar (do pic "foo~-0##.jpg") (rlist 0..5 8 12)) + + --> ("foo-000.jpg" "foo-001.jpg" "foo-002.jpg" "foo-003.jpg" + "foo-004.jpg" "foo-005.jpg" "foo-008.jpg" "foo-012.jpg") +.brev + .coNP Functions @, print @, pprint @, prinl @, pprinl @ tostring and @ tostringp .synb .mets (print < obj >> [ stream <> [ pretty-p ]]) -- cgit v1.2.3