Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/FizzBuzz/Common-Lisp/fizzbuzz-1.lisp
Normal file
7
Task/FizzBuzz/Common-Lisp/fizzbuzz-1.lisp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(defun fizzbuzz ()
|
||||
(loop for x from 1 to 100 do
|
||||
(princ (cond ((zerop (mod x 15)) "FizzBuzz")
|
||||
((zerop (mod x 3)) "Fizz")
|
||||
((zerop (mod x 5)) "Buzz")
|
||||
(t x)))
|
||||
(terpri)))
|
||||
6
Task/FizzBuzz/Common-Lisp/fizzbuzz-2.lisp
Normal file
6
Task/FizzBuzz/Common-Lisp/fizzbuzz-2.lisp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(defun fizzbuzz ()
|
||||
(loop for x from 1 to 100 do
|
||||
(format t "~&~{~A~}"
|
||||
(or (append (when (zerop (mod x 3)) '("Fizz"))
|
||||
(when (zerop (mod x 5)) '("Buzz")))
|
||||
(list x)))))
|
||||
4
Task/FizzBuzz/Common-Lisp/fizzbuzz-3.lisp
Normal file
4
Task/FizzBuzz/Common-Lisp/fizzbuzz-3.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(defun fizzbuzz ()
|
||||
(loop for n from 1 to 100
|
||||
do (format t "~&~[~[FizzBuzz~:;Fizz~]~*~:;~[Buzz~*~:;~D~]~]~%"
|
||||
(mod n 3) (mod n 5) n)))
|
||||
8
Task/FizzBuzz/Common-Lisp/fizzbuzz-4.lisp
Normal file
8
Task/FizzBuzz/Common-Lisp/fizzbuzz-4.lisp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(loop as n from 1 to 100
|
||||
as fizz = (zerop (mod n 3))
|
||||
as buzz = (zerop (mod n 5))
|
||||
as numb = (not (or fizz buzz))
|
||||
do
|
||||
(format t
|
||||
"~&~:[~;Fizz~]~:[~;Buzz~]~:[~;~D~]~%"
|
||||
fizz buzz numb n))
|
||||
8
Task/FizzBuzz/Common-Lisp/fizzbuzz-5.lisp
Normal file
8
Task/FizzBuzz/Common-Lisp/fizzbuzz-5.lisp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(format t "~{~:[~&~;~:*~:(~a~)~]~}"
|
||||
(loop as n from 1 to 100
|
||||
as f = (zerop (mod n 3))
|
||||
as b = (zerop (mod n 5))
|
||||
collect nil
|
||||
if f collect 'fizz
|
||||
if b collect 'buzz
|
||||
if (not (or f b)) collect n))
|
||||
5
Task/FizzBuzz/Common-Lisp/fizzbuzz-6.lisp
Normal file
5
Task/FizzBuzz/Common-Lisp/fizzbuzz-6.lisp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(format t "~{~{~:[~;Fizz~]~:[~;Buzz~]~:[~*~;~d~]~}~%~}"
|
||||
(loop as n from 1 to 100
|
||||
as f = (zerop (mod n 3))
|
||||
as b = (zerop (mod n 5))
|
||||
collect (list f b (not (or f b)) n)))
|
||||
16
Task/FizzBuzz/Common-Lisp/fizzbuzz-7.lisp
Normal file
16
Task/FizzBuzz/Common-Lisp/fizzbuzz-7.lisp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
(defun core (x)
|
||||
(mapcar
|
||||
#'(lambda (a b) (if (equal 0 (mod x a)) b x))
|
||||
'(3 5)
|
||||
'("fizz" "buzz")))
|
||||
|
||||
(defun filter-core (x)
|
||||
(if (equal 1 (length (remove-duplicates x)))
|
||||
(list (car x))
|
||||
(remove-if-not #'stringp x)))
|
||||
|
||||
(defun fizzbuzz (x)
|
||||
(loop for a from 1 to x do
|
||||
(print (format nil "~{~a~}" (filter-core (core a))))))
|
||||
|
||||
(fizzbuzz 100)
|
||||
20
Task/FizzBuzz/Common-Lisp/fizzbuzz-8.lisp
Normal file
20
Task/FizzBuzz/Common-Lisp/fizzbuzz-8.lisp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
;; Project : FizzBuzz
|
||||
|
||||
(defun fizzbuzz (&optional n)
|
||||
(let ((n (or n 1)))
|
||||
(if (> n 100)
|
||||
nil
|
||||
(progn
|
||||
(let ((mult-3 (is-mult-p n 3))
|
||||
(mult-5 (is-mult-p n 5)))
|
||||
(if mult-3
|
||||
(princ "Fizz"))
|
||||
(if mult-5
|
||||
(princ "Buzz"))
|
||||
(if (not (or mult-3 mult-5))
|
||||
(princ n))
|
||||
(princ #\linefeed)
|
||||
(fizzbuzz (+ n 1)))))))
|
||||
(defun is-mult-p (n multiple)
|
||||
(= (rem n multiple) 0))
|
||||
(fizzbuzz 1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue