~technomancy/fennel

5ad47050647437ff3a0c495949cbe4a1a14df071 — Mitsuhiro Nakamura 2 months ago fd04d07
Revert "Rename `accumulate` to `accum`"

This reverts commit 4efbe10bb8b465a57d1e6439fa144bb0fbdd81e3.
2 files changed, 14 insertions(+), 14 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 accum* [iter-tbl accum-expr ...]
(fn accumulate* [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,
  (accum [total 0
          _ n (pairs {:apple 2 :orange 3})]
  (accumulate [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*
 :accum accum*
 :accumulate accumulate*
 :partial partial*
 :lambda lambda*
 :pick-args pick-args*

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

(fn test-accum []
(fn test-accumulate []
  (== "(var x true)
       (let [y (accum [state :init
                       _ _ (pairs {})]
       (let [y (accumulate [state :init
                            _ _ (pairs {})]
                 (do (set x false)
                     :update))]
         [x y])"
      [true :init])
  (== "(accum [s :fen
               _ c (ipairs [:n :e :l :o]) :until (>= c :o)]
  (== "(accumulate [s :fen
                    _ c (ipairs [:n :e :l :o]) :until (>= c :o)]
         (.. s c))"
      "fennel")
  (== "(accum [n 0
               _ _ (pairs {:one 1 :two nil :three 3})]
  (== "(accumulate [n 0
                    _ _ (pairs {:one 1 :two nil :three 3})]
         (+ n 1))"
      2)
  (== "(accum [yes? true
               _ s (ipairs [:yes :no :yes])]
  (== "(accumulate [yes? true
                    _ s (ipairs [:yes :no :yes])]
         (and yes? (string.match s :yes)))"
      nil))



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