X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src.lisp;h=c1d058be485838e40adeb0e11c08878205a34118;hb=acdf969d2fa2810e98e5a3690b559bf960166300;hp=506b84f6bd5c02d486201c176bd9f4c93476370d;hpb=23c1653ae7f2dca5dec64f128d4ead2089f688bc;p=pipes.git diff --git a/src.lisp b/src.lisp index 506b84f..c1d058b 100644 --- a/src.lisp +++ b/src.lisp @@ -20,7 +20,7 @@ `(cons ,head #'(lambda () ,tail))) (defun pipe-tail (pipe) - "Return tail of pipe or list, and destructively update + "Return tail of pipe or list, and destructively update the tail if it is a function." (if (functionp (rest pipe)) (setf (rest pipe) (funcall (rest pipe))) @@ -38,7 +38,7 @@ (defun pipe-enumerate (pipe &key count key (result pipe)) "Go through all (or count) elements of pipe, possibly applying the KEY function. (Try PRINT.)" - ;; Returns RESULT, which defaults to the pipe itself. + ;; Returns RESULT, which defaults to the pipe itself. (if (or (eq pipe +empty-pipe+) (eql count 0)) result (progn @@ -61,11 +61,11 @@ if the pipe is infinite in length." (if (eq pipe +empty-pipe+) +empty-pipe+ (let ((head (pipe-head pipe)) - (tail (pipe-tail pipe))) + (tail (pipe-tail pipe))) (if (funcall predicate head) - (make-pipe head (pipe-filter predicate tail)) + (make-pipe head (pipe-filter predicate tail)) (pipe-filter predicate tail))))) - + (defun pipe-map (fn pipe) "Map fn over pipe, delaying all but the first fn call." @@ -85,10 +85,10 @@ if the pipe is infinite in length." (result (funcall fn head))) (if (or (and filter-pred (funcall filter-pred result)) result) - (make-pipe result (pipe-map-filtering fn tail filter-pred)) + (make-pipe result (pipe-map-filtering fn tail filter-pred)) (pipe-map-filtering fn tail filter-pred))))) - + (defun pipe-append (x y) "Return a pipe that appends the elements of x and y." (if (eq x +empty-pipe+) @@ -104,7 +104,7 @@ if the pipe is infinite in length." (let ((x (funcall fn (pipe-head pipe)))) (make-pipe (pipe-head x) (pipe-append (pipe-tail x) - (pipe-mappend fn (pipe-tail pipe))))))) + (pipe-mappend fn (pipe-tail pipe))))))) (defun pipe-mappend-filtering (fn pipe &optional filter-pred) "Map fn over pipe, delaying all but the first fn call, @@ -116,7 +116,7 @@ if the pipe is infinite in length." (result (funcall fn head))) (if (or (and filter-pred (funcall filter-pred result)) result) - (make-pipe (pipe-head result) - (pipe-append (pipe-tail result) - (pipe-mappend-filtering fn tail filter-pred))) + (make-pipe (pipe-head result) + (pipe-append (pipe-tail result) + (pipe-mappend-filtering fn tail filter-pred))) (pipe-mappend-filtering fn tail filter-pred)))))