Last active
April 9, 2020 23:17
-
-
Save stephan281094/b10ff933a3cca0dc44f3adce74227db0 to your computer and use it in GitHub Desktop.
My first Lisp program
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 pluralize (amount word) | |
(if (= amount 1) word (format NIL "~ds" word)) | |
) | |
(defun main () | |
(format t "~%Set a timer (in seconds): ") | |
(let | |
((idx (read))) | |
(loop | |
(format t "~s ~d left~%" idx (pluralize idx "second")) | |
(setf idx (- idx 1)) | |
(sleep 1) | |
(when (<= idx 0) | |
(format t "~%Time's up!~%") | |
(return) | |
) | |
) | |
) | |
) | |
(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
sbcl
.$ sbcl --script timer.lisp
.