[Pleac-commits] CVS: pleac/pleac/include/picolisp/ch04 commify_series, NONE, 1.1 permute, NONE, 1.1
Status: Alpha
Brought to you by:
ggc
From: Guillaume C. <gg...@us...> - 2011-01-08 13:58:19
|
Update of /cvsroot/pleac/pleac/pleac/include/picolisp/ch04 In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5496/include/picolisp/ch04 Added Files: commify_series permute words Log Message: more picolisp by alexander burger --- NEW FILE: commify_series --- #!/usr/bin/picolisp /usr/lib/picolisp/lib.l # commify_series - show proper comma insertion in list output (de Lists ("just one thing") ("Mutt" "Jeff") ("Peter" "Paul" "Mary") ("To our parents" "Mother Theresa" "God") ("pastrami" "ham and cheese" "peanut butter and jelly" "tuna") ("recycle tired, old phrases" "ponder big, happy thoughts") ("recycle tired, old phrases" "ponder big, happy thoughts" "sleep and dream peacefully") ) (de commifySeries (Lst) (ifn (cddr Lst) (glue " and " Lst) (glue (if (find '((S) (sub? "," S)) Lst) "; " ", ") (conc (head -1 Lst) (cons (pack "and " (last Lst))) ) ) ) ) (for L Lists (prinl "The list is: " (commifySeries L) ".") ) (bye) --- NEW FILE: permute --- #!/usr/bin/picolisp /usr/lib/picolisp/lib.l (load "@lib/simul.l") # For 'permute' function (in NIL (until (eof) (for F (permute (split (line) " ")) (prinl (glue " " F)) ) ) ) (bye) --- NEW FILE: words --- #!/usr/bin/picolisp /usr/lib/picolisp/lib.l # words - gather lines, present in columns (setq Data (in NIL (make (until (eof) (link (line T)) ) ) ) Maxlen (inc (length (maxi length Data))) Cols (max (/ (or (format (sys "COLUMNS")) 80) Maxlen) 1) Rows (/ (+ (length Data) Cols) Cols) Data (make (while Data (link (cut Rows 'Data)))) ) (while (find bool Data) (map '((D) (space (- Maxlen (length (prin (pop D)))))) Data ) (prinl) ) (bye) |