Tadziu Hoffmann wrote: >> I need to have [snip] a stack data structure. > > Here's a very rudimentary implementation using strings -- items > on the stack cannot contain spaces, and no error checking is > performed, but you get the idea. If necessary, the macros > can be generalized to accept the name of the stack string as > argument (instead of it being hard-coded), so that multiple > stacks can be handled simultaneously using the same macros.
Excellent! I need to hunt around and see if it's already somewhere in the code (maybe someone else has already been smart, and I don;'t want to duplicate) but if not, I'll add something like this to m.tmac. That'll *sure* clean up my code! > > .\" > .\" ---------------------------------------------------------------- > .de push > .ds stack \\$1 \\*[stack] > .. > .de pop > .pop1 \\$1 \\*[stack] > .. > .de pop1 > .ds \\$1 \\$2 > .shift 2 > .ds stack \\$* > .. > .\" ---------------------------------------------------------------- > .sp 2c > .push foo > pushed `foo', stack now contains `\*[stack]' > .br > .push xxx > pushed `xxx', stack now contains `\*[stack]' > .br > .push hello > pushed `hello', stack now contains `\*[stack]' > .br > .pop result > popped `\*[result]', stack now contains `\*[stack]' > .br > .push world > pushed `world', stack now contains `\*[stack]' > .br > .pop result > popped `\*[result]', stack now contains `\*[stack]' > .br > .pop result > popped `\*[result]', stack now contains `\*[stack]' > .br > .pop result > popped `\*[result]', stack now contains `\*[stack]' > .br > > > >