awwx.ws

between

Like each, with also doing something in between each action

(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

unLicense

This code is in the public domain.

Contact me

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