Conditionals and Predicates

Common Lisp / Emacs Lisp Only nil (which is also the empty list) nil and false

(if (> x 0) "positive" "non-positive")

(cond ((< x 0) "negative")
      ((= x 0) "zero")
      (else "positive"))                  ; Common Lisp uses t instead of else

(case day
  ((sat sun) 'weekend)
  ((mon tue wed thu fri) 'weekday)
  (else 'unknown))

(when (> x 0) (display "positive") (newline))     ; multiple body forms, no else
(unless (> x 0) (display "not positive"))
(and (> x 0) (< x 10))                    ; short-circuit, returns the last true value
(or (lookup key) 'default)                ; returns the first true value
(not #f)                                  ; #t

7.1 Equality

Same object (pointer identity) Same object, or same number/char equal / equalp

7.2 Common Predicates

Naming conventions: ? suffix for predicates (Scheme, Clojure), -p/p suffix in Common Lisp and Emacs Lisp (evenp, string-prefix-p), ! suffix for mutation (Scheme set!, Clojure swap!).

(number? 5) (integer? 5) (string? "a") (symbol? 'a) (list? '(1)) (procedure? car)
(zero? 0) (positive? 3) (negative? -1) (even? 4) (odd? 3)