~technomancy/fennel

e79b7e08aa61edd888da4b78d59cfbb116990f5a — Mitsuhiro Nakamura 2 months ago 4f10005
Rename `accumulate` to `accum`
2 files changed, 10 insertions(+), 10 deletions(-)

M src/fennel/macros.fnl
M test/loops.fnl
M src/fennel/macros.fnl => src/fennel/macros.fnl +4 -4
@@ 149,7 149,7 @@ returns
       (tset tbl# (+ (length tbl#) 1) ,value-expr))
     tbl#))

(fn accumulate* [iter-tbl accum-expr ...]
(fn accum* [iter-tbl accum-expr ...]
  "Accumulation macro.
Similar to `collect` and `icollect`, it takes a binding table and an
expression as its arguments.


@@ 161,8 161,8 @@ evaluated, and its returned value updates the accumulating variable.
It eventually returns the final value of the accumulating variable.

For example,
  (accumulate [total 0
               _ n (pairs {:apple 2 :orange 3})]
  (accum [total 0
          _ n (pairs {:apple 2 :orange 3})]
    (+ total n))
returns
  5"


@@ 491,7 491,7 @@ Syntax:
 :with-open with-open*
 :collect collect*
 :icollect icollect*
 :accumulate accumulate*
 :accum accum*
 :partial partial*
 :lambda lambda*
 :pick-args pick-args*

M test/loops.fnl => test/loops.fnl +6 -6
@@ 35,13 35,13 @@
         (tonumber num))"
      [24 58 1999]))

(fn test-accumulate []
  (== "(accumulate [n 0
                    _ _ (pairs {:one 1 :two nil :three 3})]
(fn test-accum []
  (== "(accum [n 0
               _ _ (pairs {:one 1 :two nil :three 3})]
         (+ n 1))"
      2)
  (== "(accumulate [yes? true
                    _ s (ipairs [:yes :no :yes])]
  (== "(accum [yes? true
               _ s (ipairs [:yes :no :yes])]
         (and yes? (string.match s :yes)))"
      nil))



@@ 54,5 54,5 @@
{: test-each
 : test-for
 : test-comprehensions
 : test-accumulate
 : test-accum
 : test-conditions}