Re: How does one define a closure in m4?
"Jack J. Woehr" <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.general |
|---|---|
| Message-ID | <[email protected]> |
Doug McIlroy wrote:
> specialize(unary,binary,value) produces a unary operation
> by fixing the value of one the operands of a binary operation.
>
> define(add,`($1+$2)')
> define(div,`($1/$2)')
> define(specialize,`define($1,`$2('$`1,$3)')')
> specialize(succ,`add',1)
> specialize(half,`div',2)
>
> With these definitions, half(succ(4)) expands to ((4+1)/2)
Thanks, Doug! Works for me.
Now I've got closure on closures! :)
--
Jack J. Woehr # For in the idea of chess and the development
www.well.com/~jax # of the chess mind we have a picture of the
www.softwoehr.com # intellectual struggle of mankind. – Richard Reti