branch: externals/dash commit 91d8cb01e62bab0d6267d3d4dbcabd6da6fdea78 Author: Matus Goljer <matus.gol...@gmail.com> Commit: Matus Goljer <matus.gol...@gmail.com>
Move inits and tails under reductions in the examples --- README.md | 44 +++++++++++++++---------------- dash.texi | 80 ++++++++++++++++++++++++++++----------------------------- dev/examples.el | 20 +++++++-------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 95c6f7b..8f18045 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,8 @@ Functions reducing lists into single value. * [-running-sum](#-running-sum-list) `(list)` * [-product](#-product-list) `(list)` * [-running-product](#-running-product-list) `(list)` +* [-inits](#-inits-list) `(list)` +* [-tails](#-tails-list) `(list)` * [-min](#-min-list) `(list)` * [-min-by](#-min-by-comparator-list) `(comparator list)` * [-max](#-max-list) `(list)` @@ -214,8 +216,6 @@ Operations pretending lists are sets. * [-intersection](#-intersection-list-list2) `(list list2)` * [-powerset](#-powerset-list) `(list)` * [-permutations](#-permutations-list) `(list)` -* [-inits](#-inits-list) `(list)` -* [-tails](#-tails-list) `(list)` * [-distinct](#-distinct-list) `(list)` ### Other list operations @@ -1023,6 +1023,26 @@ Return a list with running products of items in `list`. (-running-product '()) ;; Error ``` +#### -inits `(list)` + +Return all prefixes of `list`. + +```el +(-inits '(1 2 3 4)) ;; => '(nil (1) (1 2) (1 2 3) (1 2 3 4)) +(-inits nil) ;; => '(nil) +(-inits '(1)) ;; => '(nil (1)) +``` + +#### -tails `(list)` + +Return all suffixes of `list` + +```el +(-tails '(1 2 3 4)) ;; => '((1 2 3 4) (2 3 4) (3 4) (4) nil) +(-tails nil) ;; => '(nil) +(-tails '(1)) ;; => '((1) nil) +``` + #### -min `(list)` Return the smallest value from `list` of numbers or markers. @@ -1569,26 +1589,6 @@ Return the permutations of `list`. (-permutations '(a b c)) ;; => '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a)) ``` -#### -inits `(list)` - -Return all prefixes of `list`. - -```el -(-inits '(1 2 3 4)) ;; => '(nil (1) (1 2) (1 2 3) (1 2 3 4)) -(-inits nil) ;; => '(nil) -(-inits '(1)) ;; => '(nil (1)) -``` - -#### -tails `(list)` - -Return all suffixes of `list` - -```el -(-tails '(1 2 3 4)) ;; => '((1 2 3 4) (2 3 4) (3 4) (4) nil) -(-tails nil) ;; => '(nil) -(-tails '(1)) ;; => '((1) nil) -``` - #### -distinct `(list)` Return a new list with all duplicates removed. diff --git a/dash.texi b/dash.texi index e0737a7..eb741f3 100644 --- a/dash.texi +++ b/dash.texi @@ -1376,6 +1376,46 @@ Return a list with running products of items in @var{list}. @end example @end defun +@anchor{-inits} +@defun -inits (list) +Return all prefixes of @var{list}. + +@example +@group +(-inits '(1 2 3 4)) + @result{} '(nil (1) (1 2) (1 2 3) (1 2 3 4)) +@end group +@group +(-inits nil) + @result{} '(nil) +@end group +@group +(-inits '(1)) + @result{} '(nil (1)) +@end group +@end example +@end defun + +@anchor{-tails} +@defun -tails (list) +Return all suffixes of @var{list} + +@example +@group +(-tails '(1 2 3 4)) + @result{} '((1 2 3 4) (2 3 4) (3 4) (4) nil) +@end group +@group +(-tails nil) + @result{} '(nil) +@end group +@group +(-tails '(1)) + @result{} '((1) nil) +@end group +@end example +@end defun + @anchor{-min} @defun -min (list) Return the smallest value from @var{list} of numbers or markers. @@ -2349,46 +2389,6 @@ Return the permutations of @var{list}. @end example @end defun -@anchor{-inits} -@defun -inits (list) -Return all prefixes of @var{list}. - -@example -@group -(-inits '(1 2 3 4)) - @result{} '(nil (1) (1 2) (1 2 3) (1 2 3 4)) -@end group -@group -(-inits nil) - @result{} '(nil) -@end group -@group -(-inits '(1)) - @result{} '(nil (1)) -@end group -@end example -@end defun - -@anchor{-tails} -@defun -tails (list) -Return all suffixes of @var{list} - -@example -@group -(-tails '(1 2 3 4)) - @result{} '((1 2 3 4) (2 3 4) (3 4) (4) nil) -@end group -@group -(-tails nil) - @result{} '(nil) -@end group -@group -(-tails '(1)) - @result{} '((1) nil) -@end group -@end example -@end defun - @anchor{-distinct} @defun -distinct (list) Return a new list with all duplicates removed. diff --git a/dev/examples.el b/dev/examples.el index 3b63879..ed6c127 100644 --- a/dev/examples.el +++ b/dev/examples.el @@ -377,6 +377,16 @@ new list." (-running-product '(1)) => '(1) (-running-product '()) !!> error) + (defexamples -inits + (-inits '(1 2 3 4)) => '(nil (1) (1 2) (1 2 3) (1 2 3 4)) + (-inits nil) => '(nil) + (-inits '(1)) => '(nil (1))) + + (defexamples -tails + (-tails '(1 2 3 4)) => '((1 2 3 4) (2 3 4) (3 4) (4) nil) + (-tails nil) => '(nil) + (-tails '(1)) => '((1) nil)) + (defexamples -min (-min '(0)) => 0 (-min '(3 2 1)) => 1 @@ -637,16 +647,6 @@ new list." (-permutations '(1 2)) => '((1 2) (2 1)) (-permutations '(a b c)) => '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))) - (defexamples -inits - (-inits '(1 2 3 4)) => '(nil (1) (1 2) (1 2 3) (1 2 3 4)) - (-inits nil) => '(nil) - (-inits '(1)) => '(nil (1))) - - (defexamples -tails - (-tails '(1 2 3 4)) => '((1 2 3 4) (2 3 4) (3 4) (4) nil) - (-tails nil) => '(nil) - (-tails '(1)) => '((1) nil)) - (defexamples -distinct (-distinct '()) => '() (-distinct '(1 2 2 4)) => '(1 2 4)))