Re: functional programming
| Newsgroups | gmane.comp.gnu.m4.general |
|---|---|
| Message-ID | <[email protected]> |
divert(`-1')dnl there is no chance for escape changequote(`[',`]') define([BEGIN],[dnl]) define([END],[dnl]) BEGIN. calc(X)(y)=>`X(...y)' define([calc],[$1(pushdef([$1],[_$1])define([_$1],[$@,)])])_$1([$@)]) dnl X( - - - - - - - - - - - - - - - - - - - - - - - - ->\ dnl -->\ | dnl |pushdef(X,_X) | dnl +-----------------+ | dnl |define(_X),`$@,)' | dnl +---------------------+ | dnl |_X(...y) | dnl +-------->) END. divert[]dnl calc(eval)(1+1)Define a macro that returns by invoking its anonymous arg$1 expecting the result of collecting arguments during its redefinition when it would be invoked. This is currying over arguments on a built-in macro-that accepts-numeric-input. Thus calc() has a type by means of the operations restricted to it by -jection; invoking it with the resulting collected list as arguments. Cheers _______________________________________________ m4-discuss mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-discuss