branch: externals/dash commit 14f76df8006715a5030f9bdfab91300e833576c4 Author: Matus Goljer <matus.gol...@gmail.com> Commit: Matus Goljer <matus.gol...@gmail.com>
Update docs --- README.md | 24 ++++++++++++++++ dash.info | 80 +++++++++++++++++++++++++++++++++++------------------- dash.texi | 38 ++++++++++++++++++++++++++ readme-template.md | 1 + 4 files changed, 115 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 1070672..aa9deeb 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,8 @@ Functions iterating over lists for side-effect only. * [-each](#-each-list-fn) `(list fn)` * [-each-while](#-each-while-list-pred-fn) `(list pred fn)` * [-each-indexed](#-each-indexed-list-fn) `(list fn)` +* [-each-r](#-each-r-list-fn) `(list fn)` +* [-each-r-while](#-each-r-while-list-pred-fn) `(list pred fn)` * [-dotimes](#-dotimes-num-fn) `(num fn)` * [-doto](#-doto-eval-initial-value-rest-forms) `(eval-initial-value &rest forms)` @@ -2531,6 +2533,27 @@ See also: [`-map-indexed`](#-map-indexed-fn-list). (let (s) (--each-indexed '(a b c) (setq s (cons (list it it-index) s))) s) ;; => '((c 2) (b 1) (a 0)) ``` +#### -each-r `(list fn)` + +Call `fn` with every item in `list` in reversed order. + Return nil, used for side-effects only. + +```el +(let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons item s))))) ;; => nil +(let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons item s)))) s) ;; => '(1 2 3) +(let (s) (--each-r '(1 2 3) (setq s (cons it s))) s) ;; => '(1 2 3) +``` + +#### -each-r-while `(list pred fn)` + +Call `fn` with every item in reversed `list` while (`pred` item) is non-nil. +Return nil, used for side-effects only. + +```el +(let (s) (-each-r-while '(2 4 5 6) 'even? (lambda (item) (!cons item s))) s) ;; => '(6) +(let (s) (--each-r-while '(1 2 3 4) (>= it 3) (!cons it s)) s) ;; => '(3 4) +``` + #### -dotimes `(num fn)` Repeatedly calls `fn` (presumably for side-effects) passing in integers from 0 through `num-1`. @@ -3001,6 +3024,7 @@ things compatible but no future guarantees are made. - [William West](https://github.com/occidens) made `-fixfn` more robust at handling floats. - [Cam Saül](https://github.com/camsaul) contributed `-some->`, `-some->>`, and `-some-->`. - [Basil L. Contovounesios](https://github.com/basil-conto) contributed `-common-prefix`. + - [Paul Pogonyshev](https://github.com/doublep) contributed `-each-r` and `-each-r-while`. Thanks! diff --git a/dash.info b/dash.info index e92ab33..4927f60 100644 --- a/dash.info +++ b/dash.info @@ -2455,6 +2455,26 @@ Functions iterating over lists for side-effect only. (let (s) (--each-indexed '(a b c) (setq s (cons (list it it-index) s))) s) ⇒ '((c 2) (b 1) (a 0)) + -- Function: -each-r (list fn) + Call FN with every item in LIST in reversed order. Return nil, + used for side-effects only. + + (let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons item s))))) + ⇒ nil + (let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons item s)))) s) + ⇒ '(1 2 3) + (let (s) (--each-r '(1 2 3) (setq s (cons it s))) s) + ⇒ '(1 2 3) + + -- Function: -each-r-while (list pred fn) + Call FN with every item in reversed LIST while (PRED item) is + non-nil. Return nil, used for side-effects only. + + (let (s) (-each-r-while '(2 4 5 6) 'even? (lambda (item) (!cons item s))) s) + ⇒ '(6) + (let (s) (--each-r-while '(1 2 3 4) (>= it 3) (!cons it s)) s) + ⇒ '(3 4) + -- Function: -dotimes (num fn) Repeatedly calls FN (presumably for side-effects) passing in integers from 0 through NUM-1. @@ -2958,13 +2978,15 @@ Index (line 139) * -difference: Set operations. (line 20) * -distinct: Set operations. (line 62) -* -dotimes: Side-effects. (line 41) -* -doto: Side-effects. (line 50) +* -dotimes: Side-effects. (line 61) +* -doto: Side-effects. (line 70) * -drop: Sublist selection. (line 125) * -drop-last: Sublist selection. (line 137) * -drop-while: Sublist selection. (line 158) * -each: Side-effects. (line 8) * -each-indexed: Side-effects. (line 28) +* -each-r: Side-effects. (line 41) +* -each-r-while: Side-effects. (line 52) * -each-while: Side-effects. (line 19) * -elem-index: Indexing. (line 9) * -elem-indices: Indexing. (line 21) @@ -3311,32 +3333,34 @@ Node: Side-effects82009 Ref: -each82203 Ref: -each-while82610 Ref: -each-indexed82970 -Ref: -dotimes83488 -Ref: -doto83791 -Node: Destructive operations84218 -Ref: !cons84391 -Ref: !cdr84597 -Node: Function combinators84792 -Ref: -partial85066 -Ref: -rpartial85461 -Ref: -juxt85863 -Ref: -compose86295 -Ref: -applify86853 -Ref: -on87300 -Ref: -flip87823 -Ref: -const88135 -Ref: -cut88479 -Ref: -not88965 -Ref: -orfn89275 -Ref: -andfn89709 -Ref: -iteratefn90204 -Ref: -fixfn90907 -Ref: -prodfn92476 -Node: Development93542 -Node: Contribute93891 -Node: Changes94639 -Node: Contributors97638 -Node: Index99262 +Ref: -each-r83488 +Ref: -each-r-while83921 +Ref: -dotimes84296 +Ref: -doto84599 +Node: Destructive operations85026 +Ref: !cons85199 +Ref: !cdr85405 +Node: Function combinators85600 +Ref: -partial85874 +Ref: -rpartial86269 +Ref: -juxt86671 +Ref: -compose87103 +Ref: -applify87661 +Ref: -on88108 +Ref: -flip88631 +Ref: -const88943 +Ref: -cut89287 +Ref: -not89773 +Ref: -orfn90083 +Ref: -andfn90517 +Ref: -iteratefn91012 +Ref: -fixfn91715 +Ref: -prodfn93284 +Node: Development94350 +Node: Contribute94699 +Node: Changes95447 +Node: Contributors98446 +Node: Index100070 End Tag Table diff --git a/dash.texi b/dash.texi index 2243a34..9a4ea91 100644 --- a/dash.texi +++ b/dash.texi @@ -3837,6 +3837,44 @@ See also: @code{-map-indexed} (@pxref{-map-indexed}). @end example @end defun +@anchor{-each-r} +@defun -each-r (list fn) +Call @var{fn} with every item in @var{list} in reversed order. + Return nil, used for side-effects only. + +@example +@group +(let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons item s))))) + @result{} nil +@end group +@group +(let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons item s)))) s) + @result{} '(1 2 3) +@end group +@group +(let (s) (--each-r '(1 2 3) (setq s (cons it s))) s) + @result{} '(1 2 3) +@end group +@end example +@end defun + +@anchor{-each-r-while} +@defun -each-r-while (list pred fn) +Call @var{fn} with every item in reversed @var{list} while (@var{pred} item) is non-nil. +Return nil, used for side-effects only. + +@example +@group +(let (s) (-each-r-while '(2 4 5 6) 'even? (lambda (item) (!cons item s))) s) + @result{} '(6) +@end group +@group +(let (s) (--each-r-while '(1 2 3 4) (>= it 3) (!cons it s)) s) + @result{} '(3 4) +@end group +@end example +@end defun + @anchor{-dotimes} @defun -dotimes (num fn) Repeatedly calls @var{fn} (presumably for side-effects) passing in integers from 0 through @var{num-1}. diff --git a/readme-template.md b/readme-template.md index 9643a46..7ffbe36 100644 --- a/readme-template.md +++ b/readme-template.md @@ -265,6 +265,7 @@ things compatible but no future guarantees are made. - [William West](https://github.com/occidens) made `-fixfn` more robust at handling floats. - [Cam Saül](https://github.com/camsaul) contributed `-some->`, `-some->>`, and `-some-->`. - [Basil L. Contovounesios](https://github.com/basil-conto) contributed `-common-prefix`. + - [Paul Pogonyshev](https://github.com/doublep) contributed `-each-r` and `-each-r-while`. Thanks!