2.7.5. Packing Tuples

The Felix syntax macro processor treats tuples as lists. The for val construction can be used to iterate over list contents. Two primitive macro functions are provided for constructing tuples.

The _tuple function takes one argument and makes a one element tuple. Note that the main Felix programming language does not allow one element tuples. The macro processor does though.

The _tuple_cons function takes two arguments, an element and a tuple, and constructs a single tuple starting with the first argument followed by the elements of the second argument: this is the usual list cons function of functional programming languages.

These two functions are most useful in recursive expansions, particularly when driven by user defined nontermial parses (see the next section).

Start felix section to tut/examples/mac133.flx[1 /1 ]
     1: #line 663 "./lpsrc/flx_tut_macro.pak"
     2: #include <flx.flxh>
     3: macro var x = _tuple 1;
     4: macro x = _tuple_cons (2,x);
     5: macro x = _tuple_cons (3,x);
     6: macro for val i in x do print i; print " "; done; endl;
     7: 
End felix section to tut/examples/mac133.flx[1]