-
Notifications
You must be signed in to change notification settings - Fork 0
/
fizzbuzz.lisp
28 lines (26 loc) · 946 Bytes
/
fizzbuzz.lisp
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
(defun fizzbuzz ()
(loop for i from 1 to 100 do
(let ((output (concatenate 'string
(if (zerop (mod i 3)) "Fizz" "")
(if (zerop (mod i 5)) "Buzz" ""))))
(print (if (string= output "") i output)))))
(fizzbuzz)
#|
(defun fizzbuzz ()
(loop :with ring :=
(loop :for i :from 1 :below 15
:if (zerop (mod i 3))
:collect (lambda (x)
(declare (ignore x)) "Buzz") :into result
:else :if (zerop (mod i 5))
:collect (lambda (x)
(declare (ignore x)) "Fizz") :into result
:else :collect 'identity :into result
:finally
(return (nconc
(setf result
(cons (lambda (x) (declare (ignore x)) "FizzBuzz") result))
result)))
:for i :from 1 :below 101
:do (print (funcall (car (setf ring (cdr ring))) i))))
#|