Re: A style question
Thierry Pirot wrote:
Thierry Pirot writes:
job-271842874 writes:
(defun fizz-buzz (n)
(do ((i 1 (+ i 1)))
((> i n))
(let
((fizz (= 0 (mod i 3)))
(buzz (= 0 (mod i 5))))
(if fizz (format t "Fizz"))
(if buzz (format t "Buzz"))
(format t "~A~%"
(if (or fizz buzz) "" i)))))
(fizz-buzz 100)
In a more functional style, my 2 cents,
Ups, it's late here...
CL-USER> (defun printing (i)
(format t "~a~%"
(cond
((= 0 (mod i (* 3 5))) "FizzBuzz")
((= 0 (mod i 3)) "Fizz")
((= 0 (mod i 5)) "Buzz")
(t i))))
Maybe I'm reading this incorrectly, but wouldn't that always print i?
Printing i is mutually exclusive with printing "Fizz" and/or "Buzz".
.
Relevant Pages
- Re: A style question
... (if fizz (format t "Fizz")) ... (if (or fizz buzz) ... Someone else can do the loop version, the version with a macro that generates any possible fizz-buzz function of two small integers, the ver ... would be more Lisp-like to pass a list as the 2nd param (defun fizz-buzz (n lst) ... ... (comp.lang.lisp) - Re: frustrated by fscanf and sscanf
... there is no threads talking about reading a series of numbers. ... <snip description of input file structure> ... Your description of the file format makes no sense at all. ... along with a sample of your input file or a clearer ... (comp.lang.c) - Re: Reading and Writing to Binary files
... really used it but to look up a command every once and a while if I forgot ... > only do IO in a textual format, that is what they were made for. ... > you wonder about the binary flag passed to open, you didn't bother reading ... program uses the "istringstream" class to store the information. ... (comp.programming) - Re: TCL 8.5.0.0 beta not handling XBMs?
... I'm not aware of any reason for XBM files to be a problem in general, ... I thought the error was saying it found something nasty reading the file. ... due to the not-very-obvious format of the -bitmap option (which in turn ... (comp.lang.tcl) - Re: new for reading file containing multiple records
... I would suggest you use the built-in BioPerl method for reading ... fasta format, for example: ... push @seqs, $seq->seq; ... (perl.beginners) |
|