From 387bd8e98cb5fc96890add5817e1646f3a36dc28 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Sun, 28 Oct 2012 23:01:37 +0900 Subject: [PATCH] =?utf8?q?EmacsLisp=E7=89=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- emacslisp/.gitignore | 1 + emacslisp/fizzbuzz.el | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 emacslisp/.gitignore create mode 100644 emacslisp/fizzbuzz.el 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)))) -- 2.18.0