Re: A style question



"Tim Bradshaw" <tfb+google@xxxxxxxx> writes:
Incidentally, I'm deeply disappointed in the quality of answers in
this thread. In the elder days there would have been at least a few
followups showing how to do this in the proper "FORMAT string
indistinguishable from line noise" way. No true CL programmer ever
uses any other construct when the problem can be solved with a
combination of FORMAT, LOOP & GO (FORMAT being always preferable,
obviously). There may yet be those reading cll who know this, though
I suspect they have all gone into the west now.

I'm not a good practitioner of FORMAT, but there needs to be at least
one FORMAT solution presented.

(defun fizz-buzz (n)
(loop for i from 1 to n do
(format t "~[~d~;Fizz~;Buzz~;FizzBuzz~]~%"
(+ (if (zerop (mod i 3)) 1 0)
(if (zerop (mod i 5)) 2 0))
i)))

--
Barry Fishman
.



Relevant Pages

  • Re: Using VBA need to add a text box to a form
    ... The loop will be created with: ... Since you already have a reference to txt, you can assign the format ... Allen Browne - Microsoft MVP. ... I am not even sure you are doing this in design view. ...
    (microsoft.public.access.formscoding)
  • Re: is it effective/better
    ... i dont know whether what i have written is an effective solution. ... do (loop ... initially (format t "~%~VA" ... (defun pascal-triangle (n) ...
    (comp.lang.lisp)
  • Re: sending a format result to a string variable
    ... "unused" argument to format. ... that the format string make an honest attempt to consume the other ... The result of your code is that the loop is executed *before* the outer ... better to use progn to ensure this kind of order. ...
    (comp.lang.lisp)
  • Re: whats the best way to do this?
    ... "t then nil" thing is a little cutesy, ... so I'd go with the LOOP version. ... Hey, this was supposed to be LOOP weekend, not FORMAT. ... You are a newbie and you haven't answered my: ...
    (comp.lang.lisp)
  • Re: string formatting with mapping & *... is this a bug?
    ... Pierre Fortin wrote: ... Ah, sorry, my favourite idiom to avoid the boilerplate of ... reference loop) so I should remember to 'del self.self' after it... ... you SHOULD hoist the "real format" out of the ...
    (comp.lang.python)