diff --git a/README.md b/README.md index 763a8ae..8fca125 100644 --- a/README.md +++ b/README.md @@ -734,6 +734,8 @@ item, etc. If `list` contains no items, return `initial-value` and In the anaphoric form `--reduce-from`, the accumulated value is exposed as `acc`. +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)" @@ -749,6 +751,8 @@ returned and `fn` is not called. Note: this function works the same as [`-reduce-from`](#-reduce-from-fn-initial-value-list) but the operation associates from right instead of from left. +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)))" @@ -766,6 +770,8 @@ reduce return the result of calling `fn` with no arguments. If In the anaphoric form `--reduce`, the accumulated value is exposed as `acc`. +See also: [`-reduce-from`](#-reduce-from-fn-initial-value-list), [`-reduce-r`](#-reduce-r-fn-list) + ```el (-reduce '- '(1 2 3 4)) ;; => -8 (-reduce (lambda (memo item) (format "%s-%s" memo item)) '(1 2 3)) ;; => "1-2-3" @@ -786,6 +792,8 @@ accumulated value. Note: this function works the same as [`-reduce`](#-reduce-fn-list) but the operation associates from right instead of from left. +See also: [`-reduce-r-from`](#-reduce-r-from-fn-initial-value-list), [`-reduce`](#-reduce-fn-list) + ```el (-reduce-r '- '(1 2 3 4)) ;; => -2 (-reduce-r (lambda (item memo) (format "%s-%s" memo item)) '(1 2 3)) ;; => "3-2-1" diff --git a/dash.el b/dash.el index 8a380b2..342d4a9 100644 --- a/dash.el +++ b/dash.el @@ -133,7 +133,9 @@ item, etc. If LIST contains no items, return INITIAL-VALUE and FN is not called. In the anaphoric form `--reduce-from', the accumulated value is -exposed as `acc`." +exposed as `acc`. + +See also: `-reduce', `-reduce-r'" (--reduce-from (funcall fn acc it) initial-value list)) (defmacro --reduce (form list) @@ -153,7 +155,9 @@ reduce return the result of calling FN with no arguments. If LIST has only 1 item, it is returned and FN is not called. In the anaphoric form `--reduce', the accumulated value is -exposed as `acc`." +exposed as `acc`. + +See also: `-reduce-from', `-reduce-r'" (if list (-reduce-from fn (car list) (cdr list)) (funcall fn))) @@ -164,7 +168,9 @@ the resulting expression. If LIST is empty, INITIAL-VALUE is returned and FN is not called. Note: this function works the same as `-reduce-from' but the -operation associates from right instead of from left." +operation associates from right instead of from left. + +See also: `-reduce-r', `-reduce'" (if (not list) initial-value (funcall fn (car list) (-reduce-r-from fn initial-value (cdr list))))) @@ -184,7 +190,9 @@ The first argument of FN is the new item, the second is the accumulated value. Note: this function works the same as `-reduce' but the operation -associates from right instead of from left." +associates from right instead of from left. + +See also: `-reduce-r-from', `-reduce'" (cond ((not list) (funcall fn)) ((not (cdr list)) (car list)) diff --git a/dash.texi b/dash.texi index 7dbdd2b..f566483 100644 --- a/dash.texi +++ b/dash.texi @@ -965,6 +965,8 @@ item, etc. If @var{list} contains no items, return @var{initial-value} and In the anaphoric form @code{--reduce-from}, the accumulated value is exposed as `acc`. +See also: @code{-reduce} (@pxref{-reduce}), @code{-reduce-r} (@pxref{-reduce-r}) + @example @group (-reduce-from '- 10 '(1 2 3)) @@ -990,6 +992,8 @@ returned and @var{fn} is not called. Note: this function works the same as @code{-reduce-from} (@pxref{-reduce-from}) but the operation associates from right instead of from left. +See also: @code{-reduce-r} (@pxref{-reduce-r}), @code{-reduce} (@pxref{-reduce}) + @example @group (-reduce-r-from '- 10 '(1 2 3)) @@ -1017,6 +1021,8 @@ reduce return the result of calling @var{fn} with no arguments. If In the anaphoric form @code{--reduce}, the accumulated value is exposed as `acc`. +See also: @code{-reduce-from} (@pxref{-reduce-from}), @code{-reduce-r} (@pxref{-reduce-r}) + @example @group (-reduce '- '(1 2 3 4)) @@ -1047,6 +1053,8 @@ accumulated value. Note: this function works the same as @code{-reduce} (@pxref{-reduce}) but the operation associates from right instead of from left. +See also: @code{-reduce-r-from} (@pxref{-reduce-r-from}), @code{-reduce} (@pxref{-reduce}) + @example @group (-reduce-r '- '(1 2 3 4))