1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
# CURRY-COMPOSE-READER-MACROS
Reader macros for concise expression of function partial application
and composition.
These reader macros expand into the `curry`, `rcurry` and `compose`
functions from the Alexandria library. The contents of curly brackets
are curried and the contents of square brackets are composed. The `_`
symbol inside curly brackets changes the order of arguments with
`rcurry`.
The following examples demonstrate usage.
;; partial application `curry'
(mapcar {+ 1} '(1 2 3 4)) ; => (2 3 4 5)
;; alternate order of arguments `rcurry'
(mapcar {- _ 1} '(1 2 3 4)) ; => (0 1 2 3)
;; function composition
(mapcar [#'list {* 2}] '(1 2 3 4)) ; => ((2) (4) (6) (8))
To use call `enable-curry-compose-reader-macros` from within
`eval-when` to ensure that reader macros are defined for both
compilation and execution.
(eval-when (:compile-toplevel :load-toplevel :execute)
(enable-curry-compose-reader-macros))
|