Pretty printing in newLISP is optimized for saving/sourceing contents with "save" or "source", saving content with 'set' statements:
Code: Select all
> (set 'l (map list (randomize (sequence 1 20)) (sequence 1 20)))
((7 1) (6 2) (18 3) (19 4) (14 5) (13 6) (3 7) (12 8) (9 9) (16 10)
(4 11)
(2 12)
(8 13)
(15 14)
(5 15)
(11 16)
(10 17)
(17 18)
(1 19)
(20 20))
> (save "list" 'l)
true
> !cat list
(set 'l '(
(7 1)
(6 2)
(18 3)
(19 4)
(14 5)
(13 6)
(3 7)
(12 8)
(9 9)
(16 10)
(4 11)
(2 12)
(8 13)
(15 14)
(5 15)
(11 16)
(10 17)
(17 18)
(1 19)
(20 20)))
>
Note that 'cat' is a shell command the '!' has to come immedeately before it and in the first column and initiates the shell. Of course you also could open the file "list" in an editor.
Only a completely flat list will fill each line to the end.
Code: Select all
> (set 'l (sequence 1 100))
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
92 93 94 95 96 97 98 99 100)
> (save "list" 'l)
true
> !cat list
(set 'l '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100))
>
It is impossible to make a pretty print algorithm, which gets it right all the time. Remember that LISP has the same syntax for data and program. The current algorithm is optimized for displaying program text and does a reasonable well job on data, when using 'save' and 'source' for ouput.
Lutz