Common Lisp Package: OPTIMA.EXTRA

### [Pattern] alist Syntax: (alist (KEY . PATTERN)*) Expansion: (alist (k . p)*) => (and (assoc k p)*) Examples: (match '((1 . :one) (2 . :two) (3 . :three)) ((alist (1 . x) (3 . y)) (list x y))) => (:ONE :THREE) ### [Pattern] plist Syntax: (plist {KEY PATTERN}*) Expansion: (plist {k p}*) => (and (property k p)*) Examples: (match '(:name "John" :age 23) ((plist :name "John" :age age) age)) => 23

README:

FUNCTION

Private

PLIST-ALIST (PLIST)

Returns an association list containing the same keys and values as the property list PLIST in the same order.

MACRO

Public

IF-MATCH (PATTERN ARG &BODY (THEN &OPTIONAL ELSE))

Equivalent to (match ARG (PATTERN THEN) (otherwise ELSE)).

LET-MATCH (BINDINGS &BODY BODY)

Similar to LET, except not only a variable but also a pattern can be used in BINDINGS.

LET-MATCH* (BINDINGS &BODY BODY)

Similar to LET-MATCH but matches sequentially.

LET-MATCH1 (PATTERN ARG &BODY BODY)

Equivalent to (let-match ((PATTERN ARG)) BODY...).

UNLESS-MATCH (PATTERN ARG &BODY BODY)

Equivalent to (match ARG (PATTERN) (otherwise BODY...)).

WHEN-MATCH (PATTERN ARG &BODY BODY)

Equivalent to (match ARG (PATTERN BODY...)).