branch: externals/dash commit 1422b70b562a9d4e198eb73e03d89f446fcf5295 Author: Matus Goljer <matus.gol...@gmail.com> Commit: Matus Goljer <matus.gol...@gmail.com>
Update info --- dash.info | 425 +++++++++++++++++++++++++++++++++----------------------------- dash.texi | 39 +++++- 2 files changed, 260 insertions(+), 204 deletions(-) diff --git a/dash.info b/dash.info index afc83d3..f2b088a 100644 --- a/dash.info +++ b/dash.info @@ -203,10 +203,9 @@ The results are collected in order and returned as new list. ⇒ '(1 4 9 16) -- Function: -map-when (pred rep list) - Return a new list where the elements in LIST that does not match - the PRED function are unchanged, and where the elements in LIST - that do match the PRED function are mapped through the REP - function. + Return a new list where the elements in LIST that do not match the + PRED function are unchanged, and where the elements in LIST that do + match the PRED function are mapped through the REP function. Alias: ‘-replace-where’ @@ -319,6 +318,8 @@ The results are collected in order and returned as new list. -- Function: -copy (arg) Create a shallow copy of LIST. + (fn LIST) + (-copy '(1 2 3)) ⇒ '(1 2 3) (let ((a '(1 2 3))) (eq a (-copy a))) @@ -451,6 +452,8 @@ Functions returning a sublist of the original list. See also: ‘-drop-last’ (*note -drop-last::) + (fn N LIST) + (-drop 3 '(1 2 3 4 5)) ⇒ '(4 5) (-drop 17 '(1 2 3 4 5)) @@ -1443,7 +1446,7 @@ Other list functions not fit to be classified elsewhere. list of cons cells. Otherwise, return the groupings as a list of lists. - Please note! This distinction is being removed in an upcoming 2.0 + Please note! This distinction is being removed in an upcoming 3.0 release of Dash. If you rely on this behavior, use -zip-pair instead. @@ -1462,6 +1465,23 @@ Other list functions not fit to be classified elsewhere. (-zip-fill 0 '(1 2 3 4 5) '(6 7 8 9)) ⇒ '((1 . 6) (2 . 7) (3 . 8) (4 . 9) (5 . 0)) + -- Function: -unzip (lists) + Unzip LISTS. + + This works just like ‘-zip’ (*note -zip::) but takes a list of + lists instead of a variable number of arguments, such that + + (-unzip (-zip L1 L2 L3 ...)) + + is identity (given that the lists are the same length). + + See also: ‘-zip’ (*note -zip::) + + (-unzip (-zip '(1 2 3) '(a b c) '("e" "f" "g"))) + ⇒ '((1 2 3) (a b c) ("e" "f" "g")) + (-unzip '((1 2) (3 4) (5 6) (7 8) (9 10))) + ⇒ '((1 3 5 7 9) (2 4 6 8 10)) + -- Function: -cycle (list) Return an infinite copy of LIST that will cycle through the elements and repeat from the beginning. @@ -1568,6 +1588,8 @@ Other list functions not fit to be classified elsewhere. -- Function: -first-item (list) Return the first item of LIST, or nil on an empty list. + (fn LIST) + (-first-item '(1 2 3)) ⇒ 1 (-first-item nil) @@ -2273,8 +2295,8 @@ offered in a separate package: ‘dash-functional‘. ⇒ '(1 2 3 4 5) (-map (-cut funcall <> 5) '(1+ 1- (lambda (x) (/ 1.0 x)))) ⇒ '(6 4 0.2) - (-filter (-cut < <> 5) '(1 3 5 7 9)) - ⇒ '(1 3) + (-map (-cut <> 1 2 3) (list 'list 'vector 'string)) + ⇒ '((1 2 3) [1 2 3] "") -- Function: -not (pred) Take a unary predicate PRED and return a unary predicate that @@ -2591,12 +2613,12 @@ Index * -all?: Predicates. (line 18) * -andfn: Function combinators. (line 138) -* -annotate: Maps. (line 80) +* -annotate: Maps. (line 79) * -any?: Predicates. (line 6) * -applify: Function combinators. (line 55) * -butlast: Other list operations. - (line 241) + (line 260) * -clone: Tree operations. (line 122) * -compose: Function combinators. (line 42) @@ -2606,19 +2628,19 @@ Index * -const: Function combinators. (line 92) * -contains?: Predicates. (line 57) -* -copy: Maps. (line 135) +* -copy: Maps. (line 134) * -count: Reductions. (line 89) * -cut: Function combinators. (line 104) * -cycle: Other list operations. - (line 122) + (line 139) * -difference: Set operations. (line 20) * -distinct: Set operations. (line 44) * -dotimes: Side-effects. (line 41) * -doto: Side-effects. (line 50) * -drop: Sublist selection. (line 122) -* -drop-last: Sublist selection. (line 132) -* -drop-while: Sublist selection. (line 153) +* -drop-last: Sublist selection. (line 134) +* -drop-while: Sublist selection. (line 155) * -each: Side-effects. (line 8) * -each-indexed: Side-effects. (line 28) * -each-while: Side-effects. (line 19) @@ -2629,11 +2651,11 @@ Index * -find-indices: Indexing. (line 60) * -find-last-index: Indexing. (line 46) * -first: Other list operations. - (line 188) + (line 205) * -first-item: Other list operations. - (line 225) + (line 242) * -fix: Other list operations. - (line 277) + (line 296) * -fixfn: Function combinators. (line 175) * -flatten: List to list. (line 33) @@ -2662,19 +2684,19 @@ Index * -keep: List to list. (line 8) * -lambda: Binding. (line 216) * -last: Other list operations. - (line 215) + (line 232) * -last-item: Other list operations. - (line 233) + (line 252) * -let: Binding. (line 62) * -let*: Binding. (line 196) * -list: Other list operations. - (line 264) + (line 283) * -map: Maps. (line 10) -* -map-first: Maps. (line 38) -* -map-indexed: Maps. (line 66) -* -map-last: Maps. (line 52) +* -map-first: Maps. (line 37) +* -map-indexed: Maps. (line 65) +* -map-last: Maps. (line 51) * -map-when: Maps. (line 21) -* -mapcat: Maps. (line 124) +* -mapcat: Maps. (line 123) * -max: Reductions. (line 141) * -max-by: Reductions. (line 151) * -min: Reductions. (line 117) @@ -2689,7 +2711,7 @@ Index * -orfn: Function combinators. (line 126) * -pad: Other list operations. - (line 133) + (line 150) * -partial: Function combinators. (line 9) * -partition: Partitioning. (line 74) @@ -2722,34 +2744,34 @@ Index * -rpartial: Function combinators. (line 20) * -same-items?: Predicates. (line 72) -* -select-by-indices: Sublist selection. (line 164) -* -select-column: Sublist selection. (line 194) -* -select-columns: Sublist selection. (line 175) +* -select-by-indices: Sublist selection. (line 166) +* -select-column: Sublist selection. (line 196) +* -select-columns: Sublist selection. (line 177) * -separate: Partitioning. (line 63) * -slice: Sublist selection. (line 83) * -snoc: Other list operations. (line 42) * -some: Other list operations. - (line 202) + (line 219) * -some-->: Threading macros. (line 69) * -some->: Threading macros. (line 45) * -some->>: Threading macros. (line 57) * -sort: Other list operations. - (line 251) -* -splice: Maps. (line 91) -* -splice-list: Maps. (line 111) + (line 270) +* -splice: Maps. (line 90) +* -splice-list: Maps. (line 110) * -split-at: Partitioning. (line 8) * -split-on: Partitioning. (line 28) * -split-when: Partitioning. (line 46) * -split-with: Partitioning. (line 17) * -sum: Reductions. (line 97) * -table: Other list operations. - (line 144) + (line 161) * -table-flat: Other list operations. - (line 163) + (line 180) * -take: Sublist selection. (line 99) * -take-last: Sublist selection. (line 110) -* -take-while: Sublist selection. (line 142) +* -take-while: Sublist selection. (line 144) * -tree-map: Tree operations. (line 28) * -tree-map-nodes: Tree operations. (line 39) * -tree-mapreduce: Tree operations. (line 84) @@ -2759,6 +2781,8 @@ Index * -tree-seq: Tree operations. (line 8) * -unfold: Unfolding. (line 25) * -union: Set operations. (line 8) +* -unzip: Other list operations. + (line 122) * -update-at: List to list. (line 132) * -when-let: Binding. (line 9) * -when-let*: Binding. (line 22) @@ -2780,172 +2804,173 @@ Node: Functions3749 Node: Maps4960 Ref: -map5255 Ref: -map-when5596 -Ref: -map-first6181 -Ref: -map-last6659 -Ref: -map-indexed7133 -Ref: -annotate7606 -Ref: -splice8096 -Ref: -splice-list8877 -Ref: -mapcat9339 -Ref: -copy9715 -Node: Sublist selection9903 -Ref: -filter10096 -Ref: -remove10514 -Ref: -remove-first10871 -Ref: -remove-last11398 -Ref: -remove-item11919 -Ref: -non-nil12313 -Ref: -slice12472 -Ref: -take13004 -Ref: -take-last13312 -Ref: -drop13635 -Ref: -drop-last13890 -Ref: -take-while14150 -Ref: -drop-while14500 -Ref: -select-by-indices14856 -Ref: -select-columns15370 -Ref: -select-column16076 -Node: List to list16540 -Ref: -keep16727 -Ref: -concat17230 -Ref: -flatten17527 -Ref: -flatten-n18286 -Ref: -replace18673 -Ref: -replace-first19136 -Ref: -replace-last19632 -Ref: -insert-at20121 -Ref: -replace-at20448 -Ref: -update-at20838 -Ref: -remove-at21329 -Ref: -remove-at-indices21817 -Node: Reductions22399 -Ref: -reduce-from22568 -Ref: -reduce-r-from23347 -Ref: -reduce24132 -Ref: -reduce-r24933 -Ref: -count25850 -Ref: -sum26074 -Ref: -product26263 -Ref: -min26472 -Ref: -min-by26698 -Ref: -max27221 -Ref: -max-by27446 -Node: Unfolding27974 -Ref: -iterate28213 -Ref: -unfold28658 -Node: Predicates29466 -Ref: -any?29590 -Ref: -all?29918 -Ref: -none?30248 -Ref: -only-some?30550 -Ref: -contains?31035 -Ref: -same-items?31424 -Ref: -is-prefix?31809 -Ref: -is-suffix?32132 -Ref: -is-infix?32455 -Node: Partitioning32809 -Ref: -split-at32997 -Ref: -split-with33282 -Ref: -split-on33685 -Ref: -split-when34361 -Ref: -separate35001 -Ref: -partition35443 -Ref: -partition-all35895 -Ref: -partition-in-steps36323 -Ref: -partition-all-in-steps36820 -Ref: -partition-by37305 -Ref: -partition-by-header37687 -Ref: -group-by38291 -Node: Indexing38728 -Ref: -elem-index38930 -Ref: -elem-indices39325 -Ref: -find-index39708 -Ref: -find-last-index40197 -Ref: -find-indices40701 -Ref: -grade-up41109 -Ref: -grade-down41512 -Node: Set operations41922 -Ref: -union42105 -Ref: -difference42547 -Ref: -intersection42964 -Ref: -distinct43401 -Node: Other list operations43725 -Ref: -rotate43950 -Ref: -repeat44245 -Ref: -cons*44508 -Ref: -snoc44895 -Ref: -interpose45308 -Ref: -interleave45606 -Ref: -zip-with45975 -Ref: -zip46678 -Ref: -zip-fill47484 -Ref: -cycle47807 -Ref: -pad48180 -Ref: -table48503 -Ref: -table-flat49292 -Ref: -first50291 -Ref: -some50665 -Ref: -last51035 -Ref: -first-item51369 -Ref: -last-item51568 -Ref: -butlast51763 -Ref: -sort52010 -Ref: -list52499 -Ref: -fix52830 -Node: Tree operations53370 -Ref: -tree-seq53566 -Ref: -tree-map54424 -Ref: -tree-map-nodes54867 -Ref: -tree-reduce55717 -Ref: -tree-reduce-from56599 -Ref: -tree-mapreduce57200 -Ref: -tree-mapreduce-from58060 -Ref: -clone59346 -Node: Threading macros59674 -Ref: ->59819 -Ref: ->>60310 -Ref: -->60815 -Ref: -some->61341 -Ref: -some->>61715 -Ref: -some-->62151 -Node: Binding62622 -Ref: -when-let62834 -Ref: -when-let*63328 -Ref: -if-let63851 -Ref: -if-let*64246 -Ref: -let64863 -Ref: -let*69658 -Ref: -lambda70598 -Node: Side-effects71395 -Ref: -each71589 -Ref: -each-while71996 -Ref: -each-indexed72356 -Ref: -dotimes72867 -Ref: -doto73170 -Node: Destructive operations73598 -Ref: !cons73771 -Ref: !cdr73977 -Node: Function combinators74172 -Ref: -partial74446 -Ref: -rpartial74842 -Ref: -juxt75245 -Ref: -compose75677 -Ref: -applify76230 -Ref: -on76677 -Ref: -flip77200 -Ref: -const77512 -Ref: -cut77851 -Ref: -not78304 -Ref: -orfn78614 -Ref: -andfn79048 -Ref: -iteratefn79543 -Ref: -fixfn80246 -Ref: -prodfn81809 -Node: Development82871 -Node: Contribute83220 -Node: Changes83968 -Node: Contributors86966 -Node: Index88585 +Ref: -map-first6174 +Ref: -map-last6652 +Ref: -map-indexed7126 +Ref: -annotate7599 +Ref: -splice8089 +Ref: -splice-list8870 +Ref: -mapcat9332 +Ref: -copy9708 +Node: Sublist selection9912 +Ref: -filter10105 +Ref: -remove10523 +Ref: -remove-first10880 +Ref: -remove-last11407 +Ref: -remove-item11928 +Ref: -non-nil12322 +Ref: -slice12481 +Ref: -take13013 +Ref: -take-last13321 +Ref: -drop13644 +Ref: -drop-last13917 +Ref: -take-while14177 +Ref: -drop-while14527 +Ref: -select-by-indices14883 +Ref: -select-columns15397 +Ref: -select-column16103 +Node: List to list16567 +Ref: -keep16754 +Ref: -concat17257 +Ref: -flatten17554 +Ref: -flatten-n18313 +Ref: -replace18700 +Ref: -replace-first19163 +Ref: -replace-last19659 +Ref: -insert-at20148 +Ref: -replace-at20475 +Ref: -update-at20865 +Ref: -remove-at21356 +Ref: -remove-at-indices21844 +Node: Reductions22426 +Ref: -reduce-from22595 +Ref: -reduce-r-from23374 +Ref: -reduce24159 +Ref: -reduce-r24960 +Ref: -count25877 +Ref: -sum26101 +Ref: -product26290 +Ref: -min26499 +Ref: -min-by26725 +Ref: -max27248 +Ref: -max-by27473 +Node: Unfolding28001 +Ref: -iterate28240 +Ref: -unfold28685 +Node: Predicates29493 +Ref: -any?29617 +Ref: -all?29945 +Ref: -none?30275 +Ref: -only-some?30577 +Ref: -contains?31062 +Ref: -same-items?31451 +Ref: -is-prefix?31836 +Ref: -is-suffix?32159 +Ref: -is-infix?32482 +Node: Partitioning32836 +Ref: -split-at33024 +Ref: -split-with33309 +Ref: -split-on33712 +Ref: -split-when34388 +Ref: -separate35028 +Ref: -partition35470 +Ref: -partition-all35922 +Ref: -partition-in-steps36350 +Ref: -partition-all-in-steps36847 +Ref: -partition-by37332 +Ref: -partition-by-header37714 +Ref: -group-by38318 +Node: Indexing38755 +Ref: -elem-index38957 +Ref: -elem-indices39352 +Ref: -find-index39735 +Ref: -find-last-index40224 +Ref: -find-indices40728 +Ref: -grade-up41136 +Ref: -grade-down41539 +Node: Set operations41949 +Ref: -union42132 +Ref: -difference42574 +Ref: -intersection42991 +Ref: -distinct43428 +Node: Other list operations43752 +Ref: -rotate43977 +Ref: -repeat44272 +Ref: -cons*44535 +Ref: -snoc44922 +Ref: -interpose45335 +Ref: -interleave45633 +Ref: -zip-with46002 +Ref: -zip46705 +Ref: -zip-fill47511 +Ref: -unzip47834 +Ref: -cycle48368 +Ref: -pad48741 +Ref: -table49064 +Ref: -table-flat49853 +Ref: -first50852 +Ref: -some51226 +Ref: -last51596 +Ref: -first-item51930 +Ref: -last-item52145 +Ref: -butlast52340 +Ref: -sort52587 +Ref: -list53076 +Ref: -fix53407 +Node: Tree operations53947 +Ref: -tree-seq54143 +Ref: -tree-map55001 +Ref: -tree-map-nodes55444 +Ref: -tree-reduce56294 +Ref: -tree-reduce-from57176 +Ref: -tree-mapreduce57777 +Ref: -tree-mapreduce-from58637 +Ref: -clone59923 +Node: Threading macros60251 +Ref: ->60396 +Ref: ->>60887 +Ref: -->61392 +Ref: -some->61918 +Ref: -some->>62292 +Ref: -some-->62728 +Node: Binding63199 +Ref: -when-let63411 +Ref: -when-let*63905 +Ref: -if-let64428 +Ref: -if-let*64823 +Ref: -let65440 +Ref: -let*70235 +Ref: -lambda71175 +Node: Side-effects71972 +Ref: -each72166 +Ref: -each-while72573 +Ref: -each-indexed72933 +Ref: -dotimes73444 +Ref: -doto73747 +Node: Destructive operations74175 +Ref: !cons74348 +Ref: !cdr74554 +Node: Function combinators74749 +Ref: -partial75023 +Ref: -rpartial75419 +Ref: -juxt75822 +Ref: -compose76254 +Ref: -applify76807 +Ref: -on77254 +Ref: -flip77777 +Ref: -const78089 +Ref: -cut78428 +Ref: -not78914 +Ref: -orfn79224 +Ref: -andfn79658 +Ref: -iteratefn80153 +Ref: -fixfn80856 +Ref: -prodfn82419 +Node: Development83481 +Node: Contribute83830 +Node: Changes84578 +Node: Contributors87576 +Node: Index89195 End Tag Table diff --git a/dash.texi b/dash.texi index 98d74f5..e75621c 100644 --- a/dash.texi +++ b/dash.texi @@ -226,7 +226,7 @@ Return a new list consisting of the result of applying @var{fn} to the items in @anchor{-map-when} @defun -map-when (pred rep list) -Return a new list where the elements in @var{list} that does not match the @var{pred} function +Return a new list where the elements in @var{list} that do not match the @var{pred} function are unchanged, and where the elements in @var{list} that do match the @var{pred} function are mapped through the @var{rep} function. @@ -410,6 +410,8 @@ Thus function @var{fn} should return a list. @defun -copy (arg) Create a shallow copy of @var{list}. +(fn @var{list}) + @example @group (-copy '(1 2 3)) @@ -630,6 +632,8 @@ Return the tail of @var{list} without the first @var{n} items. See also: @code{-drop-last} (@pxref{-drop-last}) +(fn @var{n} @var{list}) + @example @group (-drop 3 '(1 2 3 4 5)) @@ -2276,7 +2280,7 @@ groupings are equal to the length of the shortest input list. If two lists are provided as arguments, return the groupings as a list of cons cells. Otherwise, return the groupings as a list of lists. -Please note! This distinction is being removed in an upcoming 2.0 +Please note! This distinction is being removed in an upcoming 3.0 release of Dash. If you rely on this behavior, use -zip-pair instead. @example @@ -2309,6 +2313,31 @@ longest input list. @end example @end defun +@anchor{-unzip} +@defun -unzip (lists) +Unzip @var{lists}. + +This works just like @code{-zip} (@pxref{-zip}) but takes a list of lists instead of +a variable number of arguments, such that + + (-unzip (-zip @var{l1} @var{l2} @var{l3} ...)) + +is identity (given that the lists are the same length). + +See also: @code{-zip} (@pxref{-zip}) + +@example +@group +(-unzip (-zip '(1 2 3) '(a b c) '("e" "f" "g"))) + @result{} '((1 2 3) (a b c) ("e" "f" "g")) +@end group +@group +(-unzip '((1 2) (3 4) (5 6) (7 8) (9 10))) + @result{} '((1 3 5 7 9) (2 4 6 8 10)) +@end group +@end example +@end defun + @anchor{-cycle} @defun -cycle (list) Return an infinite copy of @var{list} that will cycle through the @@ -2484,6 +2513,8 @@ Return the last x in @var{list} where (@var{pred} x) is non-nil, else nil. @defun -first-item (list) Return the first item of @var{list}, or nil on an empty list. +(fn @var{list}) + @example @group (-first-item '(1 2 3)) @@ -3569,8 +3600,8 @@ See @var{srfi-26} for detailed description. @result{} '(6 4 0.2) @end group @group -(-filter (-cut < <> 5) '(1 3 5 7 9)) - @result{} '(1 3) +(-map (-cut <> 1 2 3) (list 'list 'vector 'string)) + @result{} '((1 2 3) [1 2 3] "") @end group @end example @end defmac