Download code

Jump to: navigation, search

Back to FizzBuzz_(Lisp)

Download for Windows: single file, zip

Download for UNIX: single file, zip, tar.gz, tar.bz2

fizzbuzz.lsp

 1 (defun fbzz (left)
 2   (format t "~S " left)
 3    ( if (zerop left)
 4      ( return-from fbzz nil ) nil )
 5   ( if (zerop (mod left 3))
 6      (format t "fizz") nil)
 7   ( if (zerop (mod left 5))
 8      (format t "buzz") nil)
 9   (format t "~%")
10   ( fbzz (- left 1) )
11 )
12 (defun fzzb (limit)
13   (let (line '1)
14   (dotimes (line limit)
15     (format t ( fb_str line ))
16   ))
17 )
18 (defun fb_str (at)
19   (cond
20     ( (zerop (mod at 15))
21       ( format nil "~S fizzbuzz~%" at ) )
22     ( (zerop (mod at 3))
23       ( format nil "~S fizz~%" at ) )
24     ( (zerop (mod at 5))
25       ( format nil "~S buzz~%" at ) )
26     ( t ( format nil "~S ~%" at ) )
27   )
28 )
29 


hijacker
hijacker
hijacker
hijacker