I took the lambda term from there and I modified slightly the part which describes the IFTHEN (figured by an arrow in the wiki explanation)

IFTHEN a b appears in chemlambda as

A 1 a2 out
A a1 b 1
FO a a1 a2

which if you think a little bit, behaves like IFTHENELSE a b a.

Once I built a term like the “r” from the wiki explanation, instead of using rr, I made a graph by the following procedure:

– take the graph of r applied to something (i.e. suppose that the free out port of r is “1” then add A 1 in out)

– make a copy of that graph (i.e in mol notation duplicate the mol file of the previous graph, change the ports variable — here by adding the “a” postfix)

– then apply one to the other (i.e. modify

A 1 in out
A 1a ina outa

into

A 1 outa out,
A 1a out outa)

The initial mol file is:

A 1 outa out
A 1a out outa

L 2 3 1
A 4 7 2
A 6 5 4
FO 8 6 7

FO 3 9 10
A 9 10 8

L 2a 3a 1a
A 4a 7a 2a
A 6a 5a 4a
FO 8a 6a 7a

FO 3a 9a 10a
A 9a 10a 8a

The parameters are: cycounter=8; wei_FOFOE=0; wei_LFOELFO=0; wei_AFOAFOE=0; wei_FIFO=0; wei_FIFOE=0; wei_AL=0;