Skip to content

Instantly share code, notes, and snippets.

@stephan281094
Last active April 9, 2020 23:17
Show Gist options
  • Save stephan281094/b10ff933a3cca0dc44f3adce74227db0 to your computer and use it in GitHub Desktop.
Save stephan281094/b10ff933a3cca0dc44f3adce74227db0 to your computer and use it in GitHub Desktop.
My first Lisp program
(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)
@stephan281094
Copy link
Author

Usage:

  1. Make sure you have installed sbcl.
  2. Run $ sbcl --script timer.lisp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment