(defun charfn (char)
"maps a character to a function"
(case char
((or #\A #\a) #'car)
((or #\D #\d) #'cdr)
(t (error "unknown character-function type ~a" char))))
(defun fn-list (decon-name)
(mapcar #'charfn (butlast (rest (coerce (symbol-name decon-name) 'list)))))
;;; syntax
(defmacro defdecon (fn-name)
`(defun ,fn-name (args)
(funcall (arnesi:compose ,@(fn-list fn-name)) args)))
;;; play with it
;; test cases
(funcall (arnesi:compose 'car) (list 1 2 3)) => 1
(funcall (arnesi:compose 'caar) (list (list 1) 2 3)) => 1
;; the base works, let's test the syntax; NB, redefining a builtin will not work
(defdecon caaaaar) ; define first
(caaaaar (list (list (list (list (list 1 #\c) #\b) #\a) 2) 3)) ==> 1
:-)
just off the top of my head in 8 minutes.
make it to a reader macro if you so wish.
[Edit:
cat >> nfs://cltl3.alu.org/todo.txt
* CASE with custom tests
* COMP^H^H^H^HArnesi FFS!
]