Re: A style question



You want squiggles? How about

(format t "~&~:{ ~@[~A~]~@[~A~]~2:*~:[~:[~D~;~]~;~]~}~%"
(loop for n from 1 to 100
for fizz in '#3=(nil nil "Fizz" . #3#)
for buzz in '#5=(nil nil nil nil "Buzz" . #5#)
collect (list fizz buzz n)))

Or, if loop is for weenies, perhaps this one, with a few gratuitous
MAPs and NCONCs thrown in.

(format t "~&~:{ ~@[~A~]~@[~A~]~2:*~:[~:[~@[~C~]~C~;~]~;~]~}~%"
(cdr
(nconc
(map 'list
(lambda (ij f b) (cons f (cons b ij)))
(apply #'nconc
(map 'list
(lambda (i)
(map 'list
(lambda (j)
(list (if (eql i #\0) nil i) j))
#1="0123456789"))
#1#))
'#3=("Fizz" nil nil . #3#)
'#5=("Buzz" nil nil nil nil . #5#)))))

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
.



Relevant Pages

  • Re: Is it a bad sign...
    ... I just interned 11.6m symbols into package foobar: ... (loop for word = (read-line f nil nil) ... do (loop for i below 50 ... Timing the evaluation of (APROPOS:GIRAFFE:FOOBAR) ...
    (comp.lang.lisp)
  • Re: Strategies for defining named functions at load or compile time ?
    ... when (zerop n) return t ... try to compute a complicated unrolling of the loop each time. ... So the only thing that you need a macro for is to control the evaluation ... nil nil nil nil) ...
    (comp.lang.lisp)
  • Re: force eof on an output stream
    ... | (defun file-truncate-lines (file nlines) ... the loop needs to look something like this: ... and line = (read-line in nil nil) ... (loop for line = (read-line in nil nil) ...
    (comp.lang.lisp)
  • Re: Read-from-string
    ... (loop repeat 3 collect (read s))) ... Is there a way to circumvent this "repeat ... (loop for token = (read s nil nil nil) ... (let ((data "lala tata bobo dada nil qwerty moo goo")) ...
    (comp.lang.lisp)
  • Re: Is a new CL standard possible?
    ... (loop for elt in list ... The functionality inside LOOP is eternally ...
    (comp.lang.lisp)