Created
July 7, 2021 15:39
-
-
Save akagr/f728c58c530f24ca3a0b58e93aa40087 to your computer and use it in GitHub Desktop.
functional fizz buzz in emacs lisp
This file contains 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 divisible (a b) | |
(equal 0 (% a b))) | |
(defun to_s (item) (format "%s" item)) | |
(defun fizzbuzz (num) | |
(let* ((fizz (if (divisible num 3) "fizz" "")) | |
(buzz (if (divisible num 5) "buzz" "")) | |
(combi (concat fizz buzz)) | |
(result (if (length> combi 0) combi (to_s num)))) | |
(message result))) | |
(mapcar 'fizzbuzz (number-sequence 1 50)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment