forked from colonelpanic/dotfiles
Add headings to compose implementations
This commit is contained in:
parent
1eb3f48dfc
commit
bf6406908e
@ -435,7 +435,7 @@ imalison:named-build is used to name a lambda produced by another macro applied
|
|||||||
(cons ,builder-name args)))
|
(cons ,builder-name args)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Compose functions
|
** Compose functions
|
||||||
The composed functions can take arbitrarily many arguments and returning arbitrarily many arguments.
|
*** Arbitrary arguments at every step
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun imalison:make-list (thing)
|
(defun imalison:make-list (thing)
|
||||||
(if (listp thing)
|
(if (listp thing)
|
||||||
@ -454,8 +454,7 @@ The composed functions can take arbitrarily many arguments and returning arbitra
|
|||||||
`(apply ,(car funcs)
|
`(apply ,(car funcs)
|
||||||
(imalison:make-list (imalison:compose-helper ,(cdr funcs))))))
|
(imalison:make-list (imalison:compose-helper ,(cdr funcs))))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
*** Simpler Unary version
|
||||||
Here is a unary version which avoids all the calls to imalison:make-list
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defmacro imalison:compose-unary (&rest funcs)
|
(defmacro imalison:compose-unary (&rest funcs)
|
||||||
"Build a new function with NAME that is the composition of FUNCS."
|
"Build a new function with NAME that is the composition of FUNCS."
|
||||||
@ -468,8 +467,7 @@ Here is a unary version which avoids all the calls to imalison:make-list
|
|||||||
'arg
|
'arg
|
||||||
`(funcall ,(car funcs) (imalison:compose-helper-unary ,(cdr funcs)))))
|
`(funcall ,(car funcs) (imalison:compose-helper-unary ,(cdr funcs)))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
*** Most performant version supports macros
|
||||||
Here is a version that will support macros and requires unary functions after the first one
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defmacro imalison:compose-named-functions (arguments &rest funcs)
|
(defmacro imalison:compose-named-functions (arguments &rest funcs)
|
||||||
"Build a new function with NAME that is the composition of FUNCS."
|
"Build a new function with NAME that is the composition of FUNCS."
|
||||||
|
Loading…
Reference in New Issue
Block a user