Reading — step 1 of 5
Learn
~1 min readConditionals and Iteration
if takes a test, then-branch, optional else:
(if (> x 0) "positive" "non-positive")
For multi-statement branches, use progn:
(if (> x 0)
(progn (format t "big~%") (do-thing))
(format t "small~%"))
when is if with no else and implicit progn:
(when (= status :ready)
(log "starting")
(start))
cond for multiple branches:
(cond
((>= score 90) "A")
((>= score 80) "B")
((>= score 70) "C")
(t "F")) ; t catches the rest
Falsy values: only nil (also written as ()). Everything else is truthy, including 0 and "".
Keywords start with : and are common as enum-like values: :red :green :blue.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…