Last active
January 18, 2016 03:51
-
-
Save underhilllabs/6108908 to your computer and use it in GitHub Desktop.
Fizzbuzz in emacs lisp. It works!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun fizzbuzz () | |
"Fizzbuzz written in elisp. Count from 1 to 100, replacing numbers mod 3 with fizz, mod 5 with buzz, | |
and mod 3 and mod 5 with Fizzbuzz." | |
(interactive) | |
(insert "let's start this fizzbuzzin up!\n") | |
(mapcar (lambda (num) | |
(cond | |
;; if ((x % 3 == 0) && (x % 5 == 0)) | |
((and (= (% num 3) 0) (= (% num 5) 0)) | |
(insert "fizzbuzz\n")) | |
((= (% num 3) 0) | |
(insert "fizz\n")) | |
((= (% num 5) 0) | |
(insert "buzz\n")) | |
;; default | |
(t | |
(insert (format "%s\n" num))))) | |
;; range(1, 100) | |
(number-sequence 1 100))) |
Now let's see vim do that!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
*Scratch*
C-xC-e
after the definitionM-x fizzbuzz