next up previous contents
Next: 3.2.2 Flattening Up: 3.2 The bastron transformers Previous: 3.2 The bastron transformers

3.2.1 Untupling


Untupling (command: untup) replaces both active and passive n-ary tups by corresponding binary cns nestings, where the empty tup becomes the distinguished constant nil. This transformation, similar to list parsing in LISP's read, prepares PROLOG-like list allocation in the GWAM.

For example, the ternary tup expression in

list3(E) :- & tup(E,E,E).
becomes as in
list3(E) :- & cns(E,cns(E,cns(E,nil))).
while the equivalent tup structure (cf. subsection 3.2.4) in
list3(E) :- & [E,E,E].   % list3(E) :- & tup[E,E,E].
becomes as in
list3(E) :- & cns[E,cns[E,cns[E,nil]]].

Sample dialog (untupling of passive head and active body tups):

rfi-p> az listn([],_) :- & tup().
rfi-p> az listn([L],E) :- & tup(E|listn(L,E)).
rfi-p> untup
rfi-p> listing
listn(nil,_) :- & nil.
listn(cns[L,nil],E) :- & cns(E,listn(L,E)).

Harold Boley (