branch: externals/dash commit 4abffdc8bb15489b5e8c28c4beba19875247e3bc Author: Basil L. Contovounesios <conto...@tcd.ie> Commit: Basil L. Contovounesios <conto...@tcd.ie>
Update docs --- README.md | 53 ++++---- dash.info | 433 +++++++++++++++++++++++++++++++------------------------------- dash.texi | 55 ++++---- 3 files changed, 269 insertions(+), 272 deletions(-) diff --git a/README.md b/README.md index aa9deeb..08a37ff 100644 --- a/README.md +++ b/README.md @@ -847,7 +847,7 @@ Functions reducing lists into single value. Return the result of applying `fn` to `initial-value` and the first item in `list`, then applying `fn` to that result and the 2nd item, etc. If `list` contains no items, return `initial-value` and -`fn` is not called. +do not call `fn`. In the anaphoric form `--reduce-from`, the accumulated value is exposed as symbol `acc`. @@ -856,7 +856,7 @@ See also: [`-reduce`](#-reduce-fn-list), [`-reduce-r`](#-reduce-r-fn-list) ```el (-reduce-from '- 10 '(1 2 3)) ;; => 4 -(-reduce-from (lambda (memo item) (concat "(" memo " - " (int-to-string item) ")")) "10" '(1 2 3)) ;; => "(((10 - 1) - 2) - 3)" +(-reduce-from (lambda (memo item) (format "(%s - %d)" memo item)) "10" '(1 2 3)) ;; => "(((10 - 1) - 2) - 3)" (--reduce-from (concat acc " " it) "START" '("a" "b" "c")) ;; => "START a b c" ``` @@ -873,7 +873,7 @@ See also: [`-reduce-r`](#-reduce-r-fn-list), [`-reduce`](#-reduce-fn-list) ```el (-reduce-r-from '- 10 '(1 2 3)) ;; => -8 -(-reduce-r-from (lambda (item memo) (concat "(" (int-to-string item) " - " memo ")")) "10" '(1 2 3)) ;; => "(1 - (2 - (3 - 10)))" +(-reduce-r-from (lambda (item memo) (format "(%d - %s)" item memo)) "10" '(1 2 3)) ;; => "(1 - (2 - (3 - 10)))" (--reduce-r-from (concat it " " acc) "END" '("a" "b" "c")) ;; => "a b c END" ``` @@ -881,9 +881,9 @@ See also: [`-reduce-r`](#-reduce-r-fn-list), [`-reduce`](#-reduce-fn-list) Return the result of applying `fn` to the first 2 items in `list`, then applying `fn` to that result and the 3rd item, etc. If `list` -contains no items, `fn` must accept no arguments as well, and -reduce return the result of calling `fn` with no arguments. If -`list` has only 1 item, it is returned and `fn` is not called. +contains no items, return the result of calling `fn` with no +arguments. If `list` contains a single item, return that item +and do not call `fn`. In the anaphoric form `--reduce`, the accumulated value is exposed as symbol `acc`. @@ -892,17 +892,16 @@ See also: [`-reduce-from`](#-reduce-from-fn-initial-value-list), [`-reduce-r`](# ```el (-reduce '- '(1 2 3 4)) ;; => -8 -(-reduce (lambda (memo item) (format "%s-%s" memo item)) '(1 2 3)) ;; => "1-2-3" -(--reduce (format "%s-%s" acc it) '(1 2 3)) ;; => "1-2-3" +(-reduce 'list '(1 2 3 4)) ;; => '(((1 2) 3) 4) +(--reduce (format "%s-%d" acc it) '(1 2 3)) ;; => "1-2-3" ``` #### -reduce-r `(fn list)` Replace conses with `fn` and evaluate the resulting expression. -The final nil is ignored. If `list` contains no items, `fn` must -accept no arguments as well, and reduce return the result of -calling `fn` with no arguments. If `list` has only 1 item, it is -returned and `fn` is not called. +The final nil is ignored. If `list` contains no items, return the +result of calling `fn` with no arguments. If `list` contains a single +item, return that item and do not call `fn`. The first argument of `fn` is the new item, the second is the accumulated value. @@ -914,8 +913,8 @@ See also: [`-reduce-r-from`](#-reduce-r-from-fn-initial-value-list), [`-reduce`] ```el (-reduce-r '- '(1 2 3 4)) ;; => -2 -(-reduce-r (lambda (item memo) (format "%s-%s" memo item)) '(1 2 3)) ;; => "3-2-1" -(--reduce-r (format "%s-%s" acc it) '(1 2 3)) ;; => "3-2-1" +(-reduce-r (lambda (item memo) (format "%s-%d" memo item)) '(1 2 3)) ;; => "3-2-1" +(--reduce-r (format "%s-%d" acc it) '(1 2 3)) ;; => "3-2-1" ``` #### -reductions-from `(fn init list)` @@ -927,7 +926,7 @@ See [`-reduce-from`](#-reduce-from-fn-initial-value-list) for explanation of the See also: [`-reductions`](#-reductions-fn-list), [`-reductions-r`](#-reductions-r-fn-list), [`-reduce-r`](#-reduce-r-fn-list) ```el -(-reductions-from (lambda (a i) (format "(%s FN %s)" a i)) "INIT" '(1 2 3 4)) ;; => '("INIT" "(INIT FN 1)" "((INIT FN 1) FN 2)" "(((INIT FN 1) FN 2) FN 3)" "((((INIT FN 1) FN 2) FN 3) FN 4)") +(-reductions-from (lambda (a i) (format "(%s FN %d)" a i)) "INIT" '(1 2 3 4)) ;; => '("INIT" "(INIT FN 1)" "((INIT FN 1) FN 2)" "(((INIT FN 1) FN 2) FN 3)" "((((INIT FN 1) FN 2) FN 3) FN 4)") (-reductions-from 'max 0 '(2 1 4 3)) ;; => '(0 2 2 4 4) (-reductions-from '* 1 '(1 2 3 4)) ;; => '(1 1 2 6 24) ``` @@ -941,7 +940,7 @@ See [`-reduce-r-from`](#-reduce-r-from-fn-initial-value-list) for explanation of See also: [`-reductions-r`](#-reductions-r-fn-list), [`-reductions`](#-reductions-fn-list), [`-reduce`](#-reduce-fn-list) ```el -(-reductions-r-from (lambda (i a) (format "(%s FN %s)" i a)) "INIT" '(1 2 3 4)) ;; => '("(1 FN (2 FN (3 FN (4 FN INIT))))" "(2 FN (3 FN (4 FN INIT)))" "(3 FN (4 FN INIT))" "(4 FN INIT)" "INIT") +(-reductions-r-from (lambda (i a) (format "(%d FN %s)" i a)) "INIT" '(1 2 3 4)) ;; => '("(1 FN (2 FN (3 FN (4 FN INIT))))" "(2 FN (3 FN (4 FN INIT)))" "(3 FN (4 FN INIT))" "(4 FN INIT)" "INIT") (-reductions-r-from 'max 0 '(2 1 4 3)) ;; => '(4 4 4 3 0) (-reductions-r-from '* 1 '(1 2 3 4)) ;; => '(24 24 12 4 1) ``` @@ -955,7 +954,7 @@ See [`-reduce`](#-reduce-fn-list) for explanation of the arguments. See also: [`-reductions-from`](#-reductions-from-fn-init-list), [`-reductions-r`](#-reductions-r-fn-list), [`-reduce-r`](#-reduce-r-fn-list) ```el -(-reductions (lambda (a i) (format "(%s FN %s)" a i)) '(1 2 3 4)) ;; => '(1 "(1 FN 2)" "((1 FN 2) FN 3)" "(((1 FN 2) FN 3) FN 4)") +(-reductions (lambda (a i) (format "(%s FN %d)" a i)) '(1 2 3 4)) ;; => '(1 "(1 FN 2)" "((1 FN 2) FN 3)" "(((1 FN 2) FN 3) FN 4)") (-reductions '+ '(1 2 3 4)) ;; => '(1 3 6 10) (-reductions '* '(1 2 3 4)) ;; => '(1 2 6 24) ``` @@ -969,7 +968,7 @@ See [`-reduce-r`](#-reduce-r-fn-list) for explanation of the arguments. See also: [`-reductions-r-from`](#-reductions-r-from-fn-init-list), [`-reductions`](#-reductions-fn-list), [`-reduce`](#-reduce-fn-list) ```el -(-reductions-r (lambda (i a) (format "(%s FN %s)" i a)) '(1 2 3 4)) ;; => '("(1 FN (2 FN (3 FN 4)))" "(2 FN (3 FN 4))" "(3 FN 4)" 4) +(-reductions-r (lambda (i a) (format "(%d FN %s)" i a)) '(1 2 3 4)) ;; => '("(1 FN (2 FN (3 FN 4)))" "(2 FN (3 FN 4))" "(3 FN 4)" 4) (-reductions-r '+ '(1 2 3 4)) ;; => '(10 9 7 4) (-reductions-r '* '(1 2 3 4)) ;; => '(24 24 12 4) ``` @@ -1406,9 +1405,9 @@ other value (the body). Partition directly after each time `pred` is true on an element of `list`. ```el -(-partition-after-pred (function oddp) '()) ;; => '() -(-partition-after-pred (function oddp) '(1)) ;; => '((1)) -(-partition-after-pred (function oddp) '(0 1)) ;; => '((0 1)) +(-partition-after-pred #'oddp '()) ;; => '() +(-partition-after-pred #'oddp '(1)) ;; => '((1)) +(-partition-after-pred #'oddp '(0 1)) ;; => '((0 1)) ``` #### -partition-before-pred `(pred list)` @@ -1416,9 +1415,9 @@ Partition directly after each time `pred` is true on an element of `list`. Partition directly before each time `pred` is true on an element of `list`. ```el -(-partition-before-pred (function oddp) '()) ;; => '() -(-partition-before-pred (function oddp) '(1)) ;; => '((1)) -(-partition-before-pred (function oddp) '(0 1)) ;; => '((0) (1)) +(-partition-before-pred #'oddp '()) ;; => '() +(-partition-before-pred #'oddp '(1)) ;; => '((1)) +(-partition-before-pred #'oddp '(0 1)) ;; => '((0) (1)) ``` #### -partition-before-item `(item list)` @@ -2659,7 +2658,7 @@ expects a list with n items as arguments ```el (-map (-applify '+) '((1 1 1) (1 2 3) (5 5 5))) ;; => '(3 6 15) -(-map (-applify (lambda (a b c) (\` ((\, a) ((\, b) ((\, c))))))) '((1 1 1) (1 2 3) (5 5 5))) ;; => '((1 (1 (1))) (1 (2 (3))) (5 (5 (5)))) +(-map (-applify (lambda (a b c) `(,a (,b (,c))))) '((1 1 1) (1 2 3) (5 5 5))) ;; => '((1 (1 (1))) (1 (2 (3))) (5 (5 (5)))) (funcall (-applify '<) '(3 6)) ;; => t ``` @@ -2674,7 +2673,7 @@ In types: (b -> b -> c) -> (a -> b) -> a -> a -> c ```el (-sort (-on '< 'length) '((1 2 3) (1) (1 2))) ;; => '((1) (1 2) (1 2 3)) (-min-by (-on '> 'length) '((1 2 3) (4) (1 2))) ;; => '(4) -(-min-by (-on 'string-lessp 'int-to-string) '(2 100 22)) ;; => 22 +(-min-by (-on 'string-lessp 'number-to-string) '(2 100 22)) ;; => 22 ``` #### -flip `(func)` @@ -2823,7 +2822,7 @@ This function satisfies the following laws: (-compose (-partial 'nth n) (-prod f1 f2 ...)) = (-compose fn (-partial 'nth n)) ```el -(funcall (-prodfn '1+ '1- 'int-to-string) '(1 2 3)) ;; => '(2 1 "3") +(funcall (-prodfn '1+ '1- 'number-to-string) '(1 2 3)) ;; => '(2 1 "3") (-map (-prodfn '1+ '1-) '((1 2) (3 4) (5 6) (7 8))) ;; => '((2 1) (4 3) (6 5) (8 7)) (apply '+ (funcall (-prodfn 'length 'string-to-number) '((1 2 3) "15"))) ;; => 18 ``` diff --git a/dash.info b/dash.info index 4927f60..c2e39fb 100644 --- a/dash.info +++ b/dash.info @@ -1,4 +1,4 @@ -This is dash.info, produced by makeinfo version 6.1 from dash.texi. +This is dash.info, produced by makeinfo version 6.5 from dash.texi. This manual is for ‘dash.el’ version 2.12.1. @@ -724,8 +724,8 @@ Functions reducing lists into single value. -- Function: -reduce-from (fn initial-value list) Return the result of applying FN to INITIAL-VALUE and the first item in LIST, then applying FN to that result and the 2nd item, - etc. If LIST contains no items, return INITIAL-VALUE and FN is - not called. + etc. If LIST contains no items, return INITIAL-VALUE and do not + call FN. In the anaphoric form ‘--reduce-from’, the accumulated value is exposed as symbol ‘acc’. @@ -735,7 +735,7 @@ Functions reducing lists into single value. (-reduce-from '- 10 '(1 2 3)) ⇒ 4 - (-reduce-from (lambda (memo item) (concat "(" memo " - " (int-to-string item) ")")) "10" '(1 2 3)) + (-reduce-from (lambda (memo item) (format "(%s - %d)" memo item)) "10" '(1 2 3)) ⇒ "(((10 - 1) - 2) - 3)" (--reduce-from (concat acc " " it) "START" '("a" "b" "c")) ⇒ "START a b c" @@ -754,7 +754,7 @@ Functions reducing lists into single value. (-reduce-r-from '- 10 '(1 2 3)) ⇒ -8 - (-reduce-r-from (lambda (item memo) (concat "(" (int-to-string item) " - " memo ")")) "10" '(1 2 3)) + (-reduce-r-from (lambda (item memo) (format "(%d - %s)" item memo)) "10" '(1 2 3)) ⇒ "(1 - (2 - (3 - 10)))" (--reduce-r-from (concat it " " acc) "END" '("a" "b" "c")) ⇒ "a b c END" @@ -762,9 +762,9 @@ Functions reducing lists into single value. -- Function: -reduce (fn list) Return the result of applying FN to the first 2 items in LIST, then applying FN to that result and the 3rd item, etc. If LIST - contains no items, FN must accept no arguments as well, and - reduce return the result of calling FN with no arguments. If - LIST has only 1 item, it is returned and FN is not called. + contains no items, return the result of calling FN with no + arguments. If LIST contains a single item, return that item and + do not call FN. In the anaphoric form ‘--reduce’, the accumulated value is exposed as symbol ‘acc’. @@ -774,17 +774,16 @@ Functions reducing lists into single value. (-reduce '- '(1 2 3 4)) ⇒ -8 - (-reduce (lambda (memo item) (format "%s-%s" memo item)) '(1 2 3)) - ⇒ "1-2-3" - (--reduce (format "%s-%s" acc it) '(1 2 3)) + (-reduce 'list '(1 2 3 4)) + ⇒ '(((1 2) 3) 4) + (--reduce (format "%s-%d" acc it) '(1 2 3)) ⇒ "1-2-3" -- Function: -reduce-r (fn list) Replace conses with FN and evaluate the resulting expression. - The final nil is ignored. If LIST contains no items, FN must - accept no arguments as well, and reduce return the result of - calling FN with no arguments. If LIST has only 1 item, it is - returned and FN is not called. + The final nil is ignored. If LIST contains no items, return the + result of calling FN with no arguments. If LIST contains a + single item, return that item and do not call FN. The first argument of FN is the new item, the second is the accumulated value. @@ -797,9 +796,9 @@ Functions reducing lists into single value. (-reduce-r '- '(1 2 3 4)) ⇒ -2 - (-reduce-r (lambda (item memo) (format "%s-%s" memo item)) '(1 2 3)) + (-reduce-r (lambda (item memo) (format "%s-%d" memo item)) '(1 2 3)) ⇒ "3-2-1" - (--reduce-r (format "%s-%s" acc it) '(1 2 3)) + (--reduce-r (format "%s-%d" acc it) '(1 2 3)) ⇒ "3-2-1" -- Function: -reductions-from (fn init list) @@ -811,7 +810,7 @@ Functions reducing lists into single value. See also: ‘-reductions’ (*note -reductions::), ‘-reductions-r’ (*note -reductions-r::), ‘-reduce-r’ (*note -reduce-r::) - (-reductions-from (lambda (a i) (format "(%s FN %s)" a i)) "INIT" '(1 2 3 4)) + (-reductions-from (lambda (a i) (format "(%s FN %d)" a i)) "INIT" '(1 2 3 4)) ⇒ '("INIT" "(INIT FN 1)" "((INIT FN 1) FN 2)" "(((INIT FN 1) FN 2) FN 3)" "((((INIT FN 1) FN 2) FN 3) FN 4)") (-reductions-from 'max 0 '(2 1 4 3)) ⇒ '(0 2 2 4 4) @@ -827,7 +826,7 @@ Functions reducing lists into single value. See also: ‘-reductions-r’ (*note -reductions-r::), ‘-reductions’ (*note -reductions::), ‘-reduce’ (*note -reduce::) - (-reductions-r-from (lambda (i a) (format "(%s FN %s)" i a)) "INIT" '(1 2 3 4)) + (-reductions-r-from (lambda (i a) (format "(%d FN %s)" i a)) "INIT" '(1 2 3 4)) ⇒ '("(1 FN (2 FN (3 FN (4 FN INIT))))" "(2 FN (3 FN (4 FN INIT)))" "(3 FN (4 FN INIT))" "(4 FN INIT)" "INIT") (-reductions-r-from 'max 0 '(2 1 4 3)) ⇒ '(4 4 4 3 0) @@ -843,7 +842,7 @@ Functions reducing lists into single value. ‘-reductions-r’ (*note -reductions-r::), ‘-reduce-r’ (*note -reduce-r::) - (-reductions (lambda (a i) (format "(%s FN %s)" a i)) '(1 2 3 4)) + (-reductions (lambda (a i) (format "(%s FN %d)" a i)) '(1 2 3 4)) ⇒ '(1 "(1 FN 2)" "((1 FN 2) FN 3)" "(((1 FN 2) FN 3) FN 4)") (-reductions '+ '(1 2 3 4)) ⇒ '(1 3 6 10) @@ -859,7 +858,7 @@ Functions reducing lists into single value. See also: ‘-reductions-r-from’ (*note -reductions-r-from::), ‘-reductions’ (*note -reductions::), ‘-reduce’ (*note -reduce::) - (-reductions-r (lambda (i a) (format "(%s FN %s)" i a)) '(1 2 3 4)) + (-reductions-r (lambda (i a) (format "(%d FN %s)" i a)) '(1 2 3 4)) ⇒ '("(1 FN (2 FN (3 FN 4)))" "(2 FN (3 FN 4))" "(3 FN 4)" 4) (-reductions-r '+ '(1 2 3 4)) ⇒ '(10 9 7 4) @@ -1313,22 +1312,22 @@ Functions partitioning the input list into a list of lists. Partition directly after each time PRED is true on an element of LIST. - (-partition-after-pred (function oddp) '()) + (-partition-after-pred #'oddp '()) ⇒ '() - (-partition-after-pred (function oddp) '(1)) + (-partition-after-pred #'oddp '(1)) ⇒ '((1)) - (-partition-after-pred (function oddp) '(0 1)) + (-partition-after-pred #'oddp '(0 1)) ⇒ '((0 1)) -- Function: -partition-before-pred (pred list) Partition directly before each time PRED is true on an element of LIST. - (-partition-before-pred (function oddp) '()) + (-partition-before-pred #'oddp '()) ⇒ '() - (-partition-before-pred (function oddp) '(1)) + (-partition-before-pred #'oddp '(1)) ⇒ '((1)) - (-partition-before-pred (function oddp) '(0 1)) + (-partition-before-pred #'oddp '(0 1)) ⇒ '((0) (1)) -- Function: -partition-before-item (item list) @@ -2579,7 +2578,7 @@ offered in a separate package: ‘dash-functional‘. (-map (-applify '+) '((1 1 1) (1 2 3) (5 5 5))) ⇒ '(3 6 15) - (-map (-applify (lambda (a b c) (\` ((\, a) ((\, b) ((\, c))))))) '((1 1 1) (1 2 3) (5 5 5))) + (-map (-applify (lambda (a b c) `(,a (,b (,c))))) '((1 1 1) (1 2 3) (5 5 5))) ⇒ '((1 (1 (1))) (1 (2 (3))) (5 (5 (5)))) (funcall (-applify '<) '(3 6)) ⇒ t @@ -2595,7 +2594,7 @@ offered in a separate package: ‘dash-functional‘. ⇒ '((1) (1 2) (1 2 3)) (-min-by (-on '> 'length) '((1 2 3) (4) (1 2))) ⇒ '(4) - (-min-by (-on 'string-lessp 'int-to-string) '(2 100 22)) + (-min-by (-on 'string-lessp 'number-to-string) '(2 100 22)) ⇒ 22 -- Function: -flip (func) @@ -2745,7 +2744,7 @@ offered in a separate package: ‘dash-functional‘. (-compose f f’) (-compose g g’) ...) (-compose (-partial ’nth n) (-prod f1 f2 ...)) = (-compose fn (-partial ’nth n)) - (funcall (-prodfn '1+ '1- 'int-to-string) '(1 2 3)) + (funcall (-prodfn '1+ '1- 'number-to-string) '(1 2 3)) ⇒ '(2 1 "3") (-map (-prodfn '1+ '1-) '((1 2) (3 4) (5 6) (7 8))) ⇒ '((2 1) (4 3) (6 5) (8 7)) @@ -2961,7 +2960,7 @@ Index * -butlast: Other list operations. (line 311) * -clone: Tree operations. (line 123) -* -common-prefix: Reductions. (line 225) +* -common-prefix: Reductions. (line 224) * -compose: Function combinators. (line 42) * -concat: List to list. (line 22) @@ -2971,7 +2970,7 @@ Index (line 93) * -contains?: Predicates. (line 57) * -copy: Maps. (line 135) -* -count: Reductions. (line 153) +* -count: Reductions. (line 152) * -cut: Function combinators. (line 106) * -cycle: Other list operations. @@ -3015,7 +3014,7 @@ Index * -group-by: Partitioning. (line 187) * -if-let: Binding. (line 37) * -if-let*: Binding. (line 50) -* -inits: Reductions. (line 205) +* -inits: Reductions. (line 204) * -insert-at: List to list. (line 109) * -interleave: Other list operations. (line 66) @@ -3046,10 +3045,10 @@ Index * -map-last: Maps. (line 52) * -map-when: Maps. (line 21) * -mapcat: Maps. (line 124) -* -max: Reductions. (line 259) -* -max-by: Reductions. (line 269) -* -min: Reductions. (line 235) -* -min-by: Reductions. (line 245) +* -max: Reductions. (line 258) +* -max-by: Reductions. (line 268) +* -min: Reductions. (line 234) +* -min-by: Reductions. (line 244) * -non-nil: Sublist selection. (line 80) * -none?: Predicates. (line 30) * -not: Function combinators. @@ -3077,15 +3076,15 @@ Index * -powerset: Set operations. (line 44) * -prodfn: Function combinators. (line 212) -* -product: Reductions. (line 183) +* -product: Reductions. (line 182) * -reduce: Reductions. (line 46) * -reduce-from: Reductions. (line 8) * -reduce-r: Reductions. (line 66) * -reduce-r-from: Reductions. (line 27) -* -reductions: Reductions. (line 121) -* -reductions-from: Reductions. (line 89) -* -reductions-r: Reductions. (line 137) -* -reductions-r-from: Reductions. (line 105) +* -reductions: Reductions. (line 120) +* -reductions-from: Reductions. (line 88) +* -reductions-r: Reductions. (line 136) +* -reductions-r-from: Reductions. (line 104) * -remove: Sublist selection. (line 23) * -remove-at: List to list. (line 146) * -remove-at-indices: List to list. (line 159) @@ -3102,8 +3101,8 @@ Index (line 8) * -rpartial: Function combinators. (line 20) -* -running-product: Reductions. (line 193) -* -running-sum: Reductions. (line 171) +* -running-product: Reductions. (line 192) +* -running-sum: Reductions. (line 170) * -same-items?: Predicates. (line 72) * -second-item: Other list operations. (line 257) @@ -3128,12 +3127,12 @@ Index * -split-on: Partitioning. (line 28) * -split-when: Partitioning. (line 46) * -split-with: Partitioning. (line 17) -* -sum: Reductions. (line 161) +* -sum: Reductions. (line 160) * -table: Other list operations. (line 161) * -table-flat: Other list operations. (line 180) -* -tails: Reductions. (line 215) +* -tails: Reductions. (line 214) * -take: Sublist selection. (line 102) * -take-last: Sublist selection. (line 113) * -take-while: Sublist selection. (line 147) @@ -3190,177 +3189,177 @@ Ref: -slice12579 Ref: -take13111 Ref: -take-last13419 Ref: -drop13742 -Ref: -drop-last14015 -Ref: -take-while14275 -Ref: -drop-while14625 -Ref: -select-by-indices14981 -Ref: -select-columns15495 -Ref: -select-column16200 -Node: List to list16663 -Ref: -keep16855 -Ref: -concat17358 -Ref: -flatten17655 -Ref: -flatten-n18414 -Ref: -replace18801 -Ref: -replace-first19264 -Ref: -replace-last19760 -Ref: -insert-at20249 -Ref: -replace-at20576 -Ref: -update-at20971 -Ref: -remove-at21462 -Ref: -remove-at-indices21950 -Node: Reductions22532 -Ref: -reduce-from22701 -Ref: -reduce-r-from23487 -Ref: -reduce24272 -Ref: -reduce-r25080 -Ref: -reductions-from25996 -Ref: -reductions-r-from26711 -Ref: -reductions27436 -Ref: -reductions-r28061 -Ref: -count28696 -Ref: -sum28920 -Ref: -running-sum29109 -Ref: -product29402 -Ref: -running-product29611 -Ref: -inits29924 -Ref: -tails30172 -Ref: -common-prefix30419 -Ref: -min30713 -Ref: -min-by30939 -Ref: -max31462 -Ref: -max-by31687 -Node: Unfolding32215 -Ref: -iterate32454 -Ref: -unfold32899 -Node: Predicates33707 -Ref: -any?33831 -Ref: -all?34151 -Ref: -none?34481 -Ref: -only-some?34783 -Ref: -contains?35268 -Ref: -same-items?35657 -Ref: -is-prefix?36042 -Ref: -is-suffix?36365 -Ref: -is-infix?36688 -Node: Partitioning37042 -Ref: -split-at37230 -Ref: -split-with37515 -Ref: -split-on37918 -Ref: -split-when38594 -Ref: -separate39234 -Ref: -partition39676 -Ref: -partition-all40128 -Ref: -partition-in-steps40556 -Ref: -partition-all-in-steps41053 -Ref: -partition-by41538 -Ref: -partition-by-header41920 -Ref: -partition-after-pred42524 -Ref: -partition-before-pred42895 -Ref: -partition-before-item43273 -Ref: -partition-after-item43584 -Ref: -group-by43890 -Node: Indexing44327 -Ref: -elem-index44529 -Ref: -elem-indices44924 -Ref: -find-index45307 -Ref: -find-last-index45796 -Ref: -find-indices46300 -Ref: -grade-up46708 -Ref: -grade-down47111 -Node: Set operations47521 -Ref: -union47704 -Ref: -difference48146 -Ref: -intersection48563 -Ref: -powerset49000 -Ref: -permutations49213 -Ref: -distinct49513 -Node: Other list operations49837 -Ref: -rotate50062 -Ref: -repeat50357 -Ref: -cons*50620 -Ref: -snoc51007 -Ref: -interpose51420 -Ref: -interleave51718 -Ref: -zip-with52087 -Ref: -zip52804 -Ref: -zip-fill53610 -Ref: -unzip53933 -Ref: -cycle54467 -Ref: -pad54840 -Ref: -table55163 -Ref: -table-flat55953 -Ref: -first56962 -Ref: -some57334 -Ref: -last57643 -Ref: -first-item57977 -Ref: -second-item58393 -Ref: -third-item58673 -Ref: -fourth-item58951 -Ref: -fifth-item59217 -Ref: -last-item59479 -Ref: -butlast59771 -Ref: -sort60018 -Ref: -list60506 -Ref: -fix60837 -Node: Tree operations61377 -Ref: -tree-seq61573 -Ref: -tree-map62431 -Ref: -tree-map-nodes62874 -Ref: -tree-reduce63729 -Ref: -tree-reduce-from64611 -Ref: -tree-mapreduce65212 -Ref: -tree-mapreduce-from66072 -Ref: -clone67358 -Node: Threading macros67686 -Ref: ->67831 -Ref: ->>68323 -Ref: -->68828 -Ref: -as->69389 -Ref: -some->69844 -Ref: -some->>70218 -Ref: -some-->70654 -Node: Binding71125 -Ref: -when-let71337 -Ref: -when-let*71822 -Ref: -if-let72350 -Ref: -if-let*72745 -Ref: -let73362 -Ref: -let*79450 -Ref: -lambda80391 -Ref: -setq81193 -Node: Side-effects82009 -Ref: -each82203 -Ref: -each-while82610 -Ref: -each-indexed82970 -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 +Ref: -drop-last14016 +Ref: -take-while14277 +Ref: -drop-while14628 +Ref: -select-by-indices14984 +Ref: -select-columns15498 +Ref: -select-column16203 +Node: List to list16666 +Ref: -keep16858 +Ref: -concat17361 +Ref: -flatten17658 +Ref: -flatten-n18417 +Ref: -replace18804 +Ref: -replace-first19267 +Ref: -replace-last19763 +Ref: -insert-at20252 +Ref: -replace-at20579 +Ref: -update-at20974 +Ref: -remove-at21465 +Ref: -remove-at-indices21953 +Node: Reductions22535 +Ref: -reduce-from22704 +Ref: -reduce-r-from23470 +Ref: -reduce24237 +Ref: -reduce-r24971 +Ref: -reductions-from25841 +Ref: -reductions-r-from26556 +Ref: -reductions27281 +Ref: -reductions-r27906 +Ref: -count28541 +Ref: -sum28765 +Ref: -running-sum28955 +Ref: -product29249 +Ref: -running-product29459 +Ref: -inits29773 +Ref: -tails30021 +Ref: -common-prefix30268 +Ref: -min30562 +Ref: -min-by30788 +Ref: -max31311 +Ref: -max-by31536 +Node: Unfolding32064 +Ref: -iterate32303 +Ref: -unfold32748 +Node: Predicates33556 +Ref: -any?33680 +Ref: -all?34000 +Ref: -none?34330 +Ref: -only-some?34632 +Ref: -contains?35117 +Ref: -same-items?35506 +Ref: -is-prefix?35891 +Ref: -is-suffix?36214 +Ref: -is-infix?36537 +Node: Partitioning36891 +Ref: -split-at37079 +Ref: -split-with37364 +Ref: -split-on37767 +Ref: -split-when38443 +Ref: -separate39083 +Ref: -partition39525 +Ref: -partition-all39977 +Ref: -partition-in-steps40405 +Ref: -partition-all-in-steps40902 +Ref: -partition-by41387 +Ref: -partition-by-header41771 +Ref: -partition-after-pred42375 +Ref: -partition-before-pred42721 +Ref: -partition-before-item43074 +Ref: -partition-after-item43387 +Ref: -group-by43695 +Node: Indexing44134 +Ref: -elem-index44336 +Ref: -elem-indices44731 +Ref: -find-index45114 +Ref: -find-last-index45603 +Ref: -find-indices46107 +Ref: -grade-up46515 +Ref: -grade-down46918 +Node: Set operations47328 +Ref: -union47511 +Ref: -difference47954 +Ref: -intersection48374 +Ref: -powerset48815 +Ref: -permutations49029 +Ref: -distinct49330 +Node: Other list operations49656 +Ref: -rotate49881 +Ref: -repeat50176 +Ref: -cons*50439 +Ref: -snoc50826 +Ref: -interpose51239 +Ref: -interleave51539 +Ref: -zip-with51908 +Ref: -zip52625 +Ref: -zip-fill53431 +Ref: -unzip53754 +Ref: -cycle54288 +Ref: -pad54661 +Ref: -table54985 +Ref: -table-flat55775 +Ref: -first56784 +Ref: -some57156 +Ref: -last57465 +Ref: -first-item57799 +Ref: -second-item58215 +Ref: -third-item58495 +Ref: -fourth-item58773 +Ref: -fifth-item59039 +Ref: -last-item59301 +Ref: -butlast59593 +Ref: -sort59840 +Ref: -list60328 +Ref: -fix60659 +Node: Tree operations61199 +Ref: -tree-seq61395 +Ref: -tree-map62253 +Ref: -tree-map-nodes62696 +Ref: -tree-reduce63551 +Ref: -tree-reduce-from64433 +Ref: -tree-mapreduce65034 +Ref: -tree-mapreduce-from65894 +Ref: -clone67180 +Node: Threading macros67508 +Ref: ->67653 +Ref: ->>68145 +Ref: -->68650 +Ref: -as->69211 +Ref: -some->69666 +Ref: -some->>70040 +Ref: -some-->70476 +Node: Binding70947 +Ref: -when-let71159 +Ref: -when-let*71644 +Ref: -if-let72172 +Ref: -if-let*72567 +Ref: -let73184 +Ref: -let*79272 +Ref: -lambda80213 +Ref: -setq81015 +Node: Side-effects81831 +Ref: -each82025 +Ref: -each-while82432 +Ref: -each-indexed82792 +Ref: -each-r83310 +Ref: -each-r-while83743 +Ref: -dotimes84118 +Ref: -doto84421 +Node: Destructive operations84848 +Ref: !cons85021 +Ref: !cdr85227 +Node: Function combinators85423 +Ref: -partial85697 +Ref: -rpartial86092 +Ref: -juxt86494 +Ref: -compose86926 +Ref: -applify87484 +Ref: -on87915 +Ref: -flip88441 +Ref: -const88753 +Ref: -cut89097 +Ref: -not89583 +Ref: -orfn89893 +Ref: -andfn90327 +Ref: -iteratefn90822 +Ref: -fixfn91525 +Ref: -prodfn93094 +Node: Development94163 +Node: Contribute94512 +Node: Changes95260 +Node: Contributors98259 +Node: Index99883 End Tag Table diff --git a/dash.texi b/dash.texi index 9a4ea91..ea60abe 100644 --- a/dash.texi +++ b/dash.texi @@ -1069,7 +1069,7 @@ Functions reducing lists into single value. Return the result of applying @var{fn} to @var{initial-value} and the first item in @var{list}, then applying @var{fn} to that result and the 2nd item, etc. If @var{list} contains no items, return @var{initial-value} and -@var{fn} is not called. +do not call @var{fn}. In the anaphoric form @code{--reduce-from}, the accumulated value is exposed as symbol @code{acc}. @@ -1082,7 +1082,7 @@ See also: @code{-reduce} (@pxref{-reduce}), @code{-reduce-r} (@pxref{-reduce-r}) @result{} 4 @end group @group -(-reduce-from (lambda (memo item) (concat "(" memo " - " (int-to-string item) ")")) "10" '(1 2 3)) +(-reduce-from (lambda (memo item) (format "(%s - %d)" memo item)) "10" '(1 2 3)) @result{} "(((10 - 1) - 2) - 3)" @end group @group @@ -1109,7 +1109,7 @@ See also: @code{-reduce-r} (@pxref{-reduce-r}), @code{-reduce} (@pxref{-reduce}) @result{} -8 @end group @group -(-reduce-r-from (lambda (item memo) (concat "(" (int-to-string item) " - " memo ")")) "10" '(1 2 3)) +(-reduce-r-from (lambda (item memo) (format "(%d - %s)" item memo)) "10" '(1 2 3)) @result{} "(1 - (2 - (3 - 10)))" @end group @group @@ -1123,9 +1123,9 @@ See also: @code{-reduce-r} (@pxref{-reduce-r}), @code{-reduce} (@pxref{-reduce}) @defun -reduce (fn list) Return the result of applying @var{fn} to the first 2 items in @var{list}, then applying @var{fn} to that result and the 3rd item, etc. If @var{list} -contains no items, @var{fn} must accept no arguments as well, and -reduce return the result of calling @var{fn} with no arguments. If -@var{list} has only 1 item, it is returned and @var{fn} is not called. +contains no items, return the result of calling @var{fn} with no +arguments. If @var{list} contains a single item, return that item +and do not call @var{fn}. In the anaphoric form @code{--reduce}, the accumulated value is exposed as symbol @code{acc}. @@ -1138,11 +1138,11 @@ See also: @code{-reduce-from} (@pxref{-reduce-from}), @code{-reduce-r} (@pxref{- @result{} -8 @end group @group -(-reduce (lambda (memo item) (format "%s-%s" memo item)) '(1 2 3)) - @result{} "1-2-3" +(-reduce 'list '(1 2 3 4)) + @result{} '(((1 2) 3) 4) @end group @group -(--reduce (format "%s-%s" acc it) '(1 2 3)) +(--reduce (format "%s-%d" acc it) '(1 2 3)) @result{} "1-2-3" @end group @end example @@ -1151,10 +1151,9 @@ See also: @code{-reduce-from} (@pxref{-reduce-from}), @code{-reduce-r} (@pxref{- @anchor{-reduce-r} @defun -reduce-r (fn list) Replace conses with @var{fn} and evaluate the resulting expression. -The final nil is ignored. If @var{list} contains no items, @var{fn} must -accept no arguments as well, and reduce return the result of -calling @var{fn} with no arguments. If @var{list} has only 1 item, it is -returned and @var{fn} is not called. +The final nil is ignored. If @var{list} contains no items, return the +result of calling @var{fn} with no arguments. If @var{list} contains a single +item, return that item and do not call @var{fn}. The first argument of @var{fn} is the new item, the second is the accumulated value. @@ -1170,11 +1169,11 @@ See also: @code{-reduce-r-from} (@pxref{-reduce-r-from}), @code{-reduce} (@pxref @result{} -2 @end group @group -(-reduce-r (lambda (item memo) (format "%s-%s" memo item)) '(1 2 3)) +(-reduce-r (lambda (item memo) (format "%s-%d" memo item)) '(1 2 3)) @result{} "3-2-1" @end group @group -(--reduce-r (format "%s-%s" acc it) '(1 2 3)) +(--reduce-r (format "%s-%d" acc it) '(1 2 3)) @result{} "3-2-1" @end group @end example @@ -1190,7 +1189,7 @@ See also: @code{-reductions} (@pxref{-reductions}), @code{-reductions-r} (@pxref @example @group -(-reductions-from (lambda (a i) (format "(%s FN %s)" a i)) "INIT" '(1 2 3 4)) +(-reductions-from (lambda (a i) (format "(%s FN %d)" a i)) "INIT" '(1 2 3 4)) @result{} '("INIT" "(INIT FN 1)" "((INIT FN 1) FN 2)" "(((INIT FN 1) FN 2) FN 3)" "((((INIT FN 1) FN 2) FN 3) FN 4)") @end group @group @@ -1214,7 +1213,7 @@ See also: @code{-reductions-r} (@pxref{-reductions-r}), @code{-reductions} (@pxr @example @group -(-reductions-r-from (lambda (i a) (format "(%s FN %s)" i a)) "INIT" '(1 2 3 4)) +(-reductions-r-from (lambda (i a) (format "(%d FN %s)" i a)) "INIT" '(1 2 3 4)) @result{} '("(1 FN (2 FN (3 FN (4 FN INIT))))" "(2 FN (3 FN (4 FN INIT)))" "(3 FN (4 FN INIT))" "(4 FN INIT)" "INIT") @end group @group @@ -1238,7 +1237,7 @@ See also: @code{-reductions-from} (@pxref{-reductions-from}), @code{-reductions- @example @group -(-reductions (lambda (a i) (format "(%s FN %s)" a i)) '(1 2 3 4)) +(-reductions (lambda (a i) (format "(%s FN %d)" a i)) '(1 2 3 4)) @result{} '(1 "(1 FN 2)" "((1 FN 2) FN 3)" "(((1 FN 2) FN 3) FN 4)") @end group @group @@ -1262,7 +1261,7 @@ See also: @code{-reductions-r-from} (@pxref{-reductions-r-from}), @code{-reducti @example @group -(-reductions-r (lambda (i a) (format "(%s FN %s)" i a)) '(1 2 3 4)) +(-reductions-r (lambda (i a) (format "(%d FN %s)" i a)) '(1 2 3 4)) @result{} '("(1 FN (2 FN (3 FN 4)))" "(2 FN (3 FN 4))" "(3 FN 4)" 4) @end group @group @@ -2048,15 +2047,15 @@ Partition directly after each time @var{pred} is true on an element of @var{list @example @group -(-partition-after-pred (function oddp) '()) +(-partition-after-pred #'oddp '()) @result{} '() @end group @group -(-partition-after-pred (function oddp) '(1)) +(-partition-after-pred #'oddp '(1)) @result{} '((1)) @end group @group -(-partition-after-pred (function oddp) '(0 1)) +(-partition-after-pred #'oddp '(0 1)) @result{} '((0 1)) @end group @end example @@ -2068,15 +2067,15 @@ Partition directly before each time @var{pred} is true on an element of @var{lis @example @group -(-partition-before-pred (function oddp) '()) +(-partition-before-pred #'oddp '()) @result{} '() @end group @group -(-partition-before-pred (function oddp) '(1)) +(-partition-before-pred #'oddp '(1)) @result{} '((1)) @end group @group -(-partition-before-pred (function oddp) '(0 1)) +(-partition-before-pred #'oddp '(0 1)) @result{} '((0) (1)) @end group @end example @@ -4046,7 +4045,7 @@ expects a list with n items as arguments @result{} '(3 6 15) @end group @group -(-map (-applify (lambda (a b c) (\` ((\, a) ((\, b) ((\, c))))))) '((1 1 1) (1 2 3) (5 5 5))) +(-map (-applify (lambda (a b c) `(,a (,b (,c))))) '((1 1 1) (1 2 3) (5 5 5))) @result{} '((1 (1 (1))) (1 (2 (3))) (5 (5 (5)))) @end group @group @@ -4074,7 +4073,7 @@ In types: (b -> b -> c) -> (a -> b) -> a -> a -> c @result{} '(4) @end group @group -(-min-by (-on 'string-lessp 'int-to-string) '(2 100 22)) +(-min-by (-on 'string-lessp 'number-to-string) '(2 100 22)) @result{} 22 @end group @end example @@ -4301,7 +4300,7 @@ This function satisfies the following laws: @example @group -(funcall (-prodfn '1+ '1- 'int-to-string) '(1 2 3)) +(funcall (-prodfn '1+ '1- 'number-to-string) '(1 2 3)) @result{} '(2 1 "3") @end group @group