chiark
/
gitweb
/
~mdw
/
sod
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
72456c1
)
src/utilities.lisp (compose): Handle the case of zero arguments.
author
Mark Wooding
<mdw@distorted.org.uk>
Sat, 3 Aug 2019 22:34:59 +0000
(23:34 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sat, 3 Aug 2019 22:36:06 +0000
(23:36 +0100)
src/utilities.lisp
patch
|
blob
|
blame
|
history
diff --git
a/src/utilities.lisp
b/src/utilities.lisp
index bdcdf80f9f4076c027531582994b5102570b7b25..cb6f0ccba742b4f96afd81b86461587736877ffc 100644
(file)
--- a/
src/utilities.lisp
+++ b/
src/utilities.lisp
@@
-843,7
+843,7
@@
(defun backtrack-position (char line column)
;;; Functions.
(export 'compose)
;;; Functions.
(export 'compose)
-(defun compose (
function &rest more-
functions)
+(defun compose (
&rest
functions)
"Composition of functions. Functions are applied left-to-right.
This is the reverse order of the usual mathematical notation, but I find
"Composition of functions. Functions are applied left-to-right.
This is the reverse order of the usual mathematical notation, but I find
@@
-854,7
+854,9
@@
(defun compose (function &rest more-functions)
(labels ((compose1 (func-a func-b)
(lambda (&rest args)
(multiple-value-call func-b (apply func-a args)))))
(labels ((compose1 (func-a func-b)
(lambda (&rest args)
(multiple-value-call func-b (apply func-a args)))))
- (reduce #'compose1 more-functions :initial-value function)))
+ (if (null functions) #'values
+ (reduce #'compose1 (cdr functions)
+ :initial-value (car functions)))))
;;;--------------------------------------------------------------------------
;;; Variables.
;;;--------------------------------------------------------------------------
;;; Variables.