John Thingstad <jpthing@online.no> wrote:
+---------------
| Just read through the document "XP A Common Lisp Pretty Printing system"
| (http://dspace.mit.edu/handle/1721.1/6503)
| Wrote this trivial test:
| ...
| MY-USER 54 > (print-fact 100)
| 093 326 215 443 944 152 681 699 238 856 266 700 490 715 968 264 381 621
| 468 592 963 895 217 599 993 229 915 608
| 941 463 976 156 518 286 253 697 920 827 223 758 251 185 210 916 864 000
| 000 000 000 000 000 000 000
|
| Well particularly readable it isn't but quite powerful.
+---------------
Cool!
Hmmm... Some manipulation of *PRINT-RIGHT-MARGIN* [also see
*PRINT-MISER-WIDTH* and/or *PRINT-LENGTH*, in some cases]
might be able to get rid of those annoying short wraps:
> (let ((*print-right-margin* 40)) ; try for 10 groups per line
(print-fact 100))
093 326 215 443 944 152 681 699 238 856
266 700 490 715 968 264 381 621 468 592
963 895 217 599 993 229 915 608 941 463
976 156 518 286 253 697 920 827 223 758
251 185 210 916 864 000 000 000 000 000
000 000 000
>
+---------------
| Anyone else using the pretty printer for printing data?
+---------------
I tend to use it a lot for generating C source files,
e.g., this bit clipped from a previous article of mine
<news:F-udnZ3s2r7vWELbnZ2dnUVZ_jydnZ2d@speakeasy.net> [Sept'07]:
I use it [the |0X| printing function shown earlier]
a lot when building data initialization tables in C code:
> (let ((data (loop for i below 24 nconc (list (random 0x100000000)
(random 256))))
(instance "georgey"))
(format t "~%foo_t ~a_foos[~d] = {~
~%~{~<~%~1,68:; {~/0x/, ~2/0x/}~>~^,~}~%};~%"
instance (/ (length data) 2) data))
foo_t georgey_foos[24] = {
{0x21a41a5c, 0x87}, {0x1c63b86e, 0xb4}, {0x894c25d5, 0xa1},
{0x9979b7fe, 0xbb}, {0xc2ad44aa, 0x4d}, {0xe2826239, 0x70},
{0x053b537e, 0x05}, {0x6ac226e8, 0xbe}, {0x1252ea73, 0x20},
{0xe3001d4a, 0x12}, {0x9a006313, 0x31}, {0x299d2f64, 0x54},
{0x90feb745, 0xda}, {0xc7ed257b, 0xc1}, {0xa6e8e18a, 0x51},
{0x0fdb8569, 0xed}, {0x713c27e0, 0xa8}, {0xd975dbac, 0x2d},
{0xb4263772, 0x85}, {0xe6cdaaa9, 0x48}, {0x7db24d29, 0xf8},
{0x87e5aa36, 0xa3}, {0xb56e3dd7, 0xe2}, {0x3cf23443, 0x4e}
};
NIL
>
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607