chickadee » clojurian » and->

(and-> val forms ...)syntax

Works just like -> but will return #f in case val or any of the forms evaluates to #f. Unlike -> the forms can't be macros (since the values are collected and checked).

Examples:

(define some-alist '((a . 1) (b . 2)))

(and-> 'b (assq some-alist) cdr add1) => 3

(and-> 'c (assq some-alist) cdr add1) => #f

This syntax is essentially a shortcut for certain uses of and-let*, e.g. the above example would often be expressed like this:

(and-let* ((x 'b)
           (x (assq x some-alist))
           (x (cdr x)))
  (add1 x))