mailing-list for TeXmacs Users

Text archives Help


[TeXmacs] Macros that make macros


Chronological Thread 
  • From: "Sam Liddicott" <address@hidden>
  • To: address@hidden
  • Subject: [TeXmacs] Macros that make macros
  • Date: Wed, 14 Jul 2010 14:58:37 +0100
  • Envelope-to: address@hidden
  • Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAAXNSR0IArs4c6QAAADxQTFRF NTdQY2Z/i286eHFugnNXoJBwm5GCs5VeoqO0ua+fwLCQ4c2q19C81NDF4eLr/unQ/PTf/fXW+/rq /f/7XKo76wAAAAlwSFlzAAALEwAACxMBAJqcGAAAAi9JREFUSMetloGSqyAMRVsFNAQkxP//15cE 62rFdt/MZqbTVu/hBhLEx/qf8fgDIAN455wHyPk7wCIe9nA+fwGSH87hgD8AHPfRpy2GwdMtcBh+ mg4Ech9Ih+RNixJKDLEL0GF8VLkSojePHrDlryNijbFW8zBg8PUKbBOI6D1WCV5Rf2DzxCtgBlMs tRRVW5LyVW3ew1TfAZZ6RcQicpb4yZmaC74DJADK6BdATOrUAbJzsZie+K22ZnEBknNYysvhVH6u 1X8CqAe4DuANoPoOrAbsHXUARJ5knc5z4EyyTnHoAqj7xvkYIdk65AwhyEZKMusOIDV2QQQaCnDQ gBiDR3RdIEb5CBESt2wgQJI0Yx/Agphg1MgNsD+QkszM9wHVPx/PeQOW+fmcR9DF8+4CyCJhCuP8 fDzmBbLqs8JzMODqYNfDvKhoGYM2lDosy5jlRozccRAgrPM8iygQS3Mv87IugUgKlC7NZ6liuy4r uresVq5QuQAr09ZKEga8OkluyKXeQ6Bs3SrtqgC1pWLNqAfwDhBnB+sK8OrVL4D4h1B4zWPWhJhu gPUHKA5EwSMYUMsdQK+UKDhIOTSHeg+8HCoTOGtB/gwcl4mSdGybwXegPWhM/RHYKwchkckhUNMX 6j7ueQNScLbZZOPRxaADyO2UQCJpl7wbnE6gQ+ksWjpngxOwF1tF5ecP3R6KB+AQxPfHLncQ+nKw 06fhu68OTIfJ869eTtg22l+9zfwDK3mKl5BFHMYAAAAASUVORK5CYII=

I'm trying to define a macro which takes a macro as an argument and decomposes it into arguments and a body and constructs a new macro with the same arguments but enclosing the body inside a <with> block.


<assign|noop|<macro|x|<arg|x>>>

The purpose of the macro bt is to take all of the arguments and assemble them under the label "macro"
<assign|bt|<xmacro|d|<map-args|noop|macro|d>>>

It appears to work as this shows
Looks like Macro Definition=<bt|a|b|<compound|arg|a>>

But when I save and run it I find the literal <arg|d|2> instead of the body
<assign|dobt|<bt|a|b|<compound|arg|a>>>

Saved Macro Definition=<value|dobt>

Executed Macro Definition=<dobt|ONE|TWO>


I've been using a macro like the one below to show the decomposed macro - look-up works, but range doesn't work on a macro body and so in order to fully decompose the function visually I have to "know" the arity at the point I write the function.

<assign|juggles|<macro|m|<tree|<arg|m>=<get-label|<value|<arg|m>>>(<get-arity|<value|<arg|m>>>)|<look-up|<value|<arg|m>>|0>|<look-up|<value|<arg|m>>|1>|<look-up|<value|<arg|m>>|2>|<look-up|<value|<arg|m>>|3>|<look-up|<value|<arg|m>>|4>|<look-up|<value|<arg|m>>|5>>>>

This attempt gathers them but the tree shown has one value - which is a tuple

<assign|collect-look-up|<macro|from|data|<case|<lesseq|<get-arity|<arg|data>>|<arg|from>>|<tuple|>|<equal|<get-arity|<arg|data>>|<plus|<arg|from>|1>>|<tuple|<look-up|<arg|data>|<arg|from>>>|<merge|<tuple|<look-up|<arg|data>|<arg|from>>>|<collect-look-up|<plus|<arg|from>|1>|<arg|data>>>>>>

<assign|jiggles|<macro|m|<tree|Jiggles <arg|m>=<get-label|<value|<arg|m>>>(<get-arity|<value|<arg|m>>>)|<collect-look-up|0|<value|<arg|m>>>>>>

I've tried to expand the tuple into arguments with unquote*:
<assign|jiggles|<macro|m|<tree|Jiggles <arg|m>=<get-label|<value|<arg|m>>>(<get-arity|<value|<arg|m>>>)|<unquote*|<quote|<collect-look-up|0|<value|<arg|m>>>>>>>>

I really need something like map-tuple which works the same way map-args does; or a clear way to call a macro with a tuple that becomes arguments.

Sam


--
Sam's signature


  • [TeXmacs] Macros that make macros, Sam Liddicott, 07/14/2010

Archive powered by MHonArc 2.6.19.

Top of page