awwx.ws

between0

Like each, with also doing something in between each action

http://awwx.ws/between0.arc:

(mac between (var expr within . body)
  (w/uniq first
    `(let ,first t
       (each ,var ,expr
         (unless ,first ,within)
         (wipe ,first)
         ,@body))))

I’ve been running into this pattern in my code often enough that I thought I’d make it into a macro.

arc> (between a '(1 2 3 4) (pr ",")
       (pr a))
1,2,3,4nil

Get this hack

Download between0.arc.

Or, using the hackinator:

hack ycombinator.com/arc/arc3.1.tar \
  awwx.ws/between0.arc

License

This code may be redistributed and modified under the same terms as Arc itself.

Contact me

Twitter: awwx
Email: andrew.wilcox [at] gmail.com