Skip to content

Instantly share code, notes, and snippets.

@kazu634
Created December 8, 2011 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazu634/1446774 to your computer and use it in GitHub Desktop.
Save kazu634/1446774 to your computer and use it in GitHub Desktop.
for-each ... m4
# foreach(x, (item_1, item_2, ..., item_n), stmt)
define(`foreach', `pushdef(`$1', `')_foreach(`$1', `$2', `$3')popdef(`$1')')
define(`_arg1', `$1')
define(`_foreach',
`ifelse(`$2', `()', ,
`define(`$1', _arg1$2)$3`'_foreach(`$1', (shift$2), `$3')')')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment