LoginSignup
1
1

More than 3 years have passed since last update.

[Common Lisp] condでの条件分岐

Posted at

cond

複数の条件分岐を書ける。
if / elsif / else のようなイメージ。

  • 最後の分岐の条件には t を置くのが定石らしい。
CL-USER>
(defun cond-symbol (x)
  (cond ((eq x 'a) `(symbol is a.))
        ((eq x 'b) `(symbol is b.))
        (t '(other symbol))))
COND-SYMBOL

CL-USER> (cond-symbol 'a)
(SYMBOL IS A.)

CL-USER> (cond-symbol 'b)
(SYMBOL IS B.)

CL-USER> (cond-symbol 'c)
(OTHER SYMBOL)

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1