From: j8takagi Date: Sun, 28 Oct 2012 14:01:37 +0000 (+0900) Subject: EmacsLisp版を追加 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=387bd8e98cb5fc96890add5817e1646f3a36dc28;p=fizzbuzz.git EmacsLisp版を追加 --- diff --git a/emacslisp/.gitignore b/emacslisp/.gitignore new file mode 100644 index 0000000..c531d98 --- /dev/null +++ b/emacslisp/.gitignore @@ -0,0 +1 @@ +*.elc diff --git a/emacslisp/fizzbuzz.el b/emacslisp/fizzbuzz.el new file mode 100644 index 0000000..a2e18c2 --- /dev/null +++ b/emacslisp/fizzbuzz.el @@ -0,0 +1,19 @@ +;; fizzbuzz.el +;; ターミナルで「emacs --batch --script fizzbuzz.el」を実行 +(defun fizzbuzz (num) + (let + ((fizz (= (% num 3) 0)) + (buzz (= (% num 5) 0))) + (cond + ((and fizz buzz) "FizzBuzz") + (fizz "Fizz") + (buzz "Buzz") + (t num)))) + +(let + (i (min 1) (max 100)) + (setq i min) + (while (<= i max) + (princ (fizzbuzz i)) + (princ "\n") + (setq i (1+ i))))