It would be nice to have the possibility to define multiple patterns for a zero-dimensional table. To avoid syntactic problems, in the following I would use Define <zero-dimensional table> = <rhs>, instead of Table and Fill, but the meaning should be clear.
CF f1,f2,f3;
S x2,x3;
V p2,p3;
* Zip two functions as
* zip(f1,f2(a1,...,aN),f3(b1,...,bN)) -> f1(a1,b1,...,aN,bN).
Define zip(f1?(?a1),f2?(x2?,?a2),f3?(x3?,?a3))
= zip(f1(?a1,x2,x3),f2(?a2),f3(?a3));
Define zip(f1?(?a1),f2?(p2?,?a2),f3?(p3?,?a3))
= zip(f1(?a1,p2,p3),f2(?a2),f3(?a3));
Define zip(f1?(?a1),f2?(),f3?());
= f1(?a1);
* Example
Auto S a,b;
Auto V p,q;
CF f;
L F1 = zip(f,f(<a1>,...,<a5>),f(<b1>,...,<b5>));
L F2 = zip(f,f(<p1>,...,<p5>),f(<q1>,...,<q5>));
P;
.end
I would expect FORM automatically tries to apply
repeat;
id ifmatch->continue, zip(f1?(?a1),f2?(x2?,?a2),f3?(x3?,?a3))
= zip(f1(?a1,x2,x3),f2(?a2),f3(?a3));
id ifmatch->continue, zip(f1?(?a1),f2?(p2?,?a2),f3?(p3?,?a3))
= zip(f1(?a1,p2,p3),f2(?a2),f3(?a3));
id ifmatch->continue, zip(f1?(?a1),f2?(),f3?());
= f1(?a1);
label continue;
endrepeat;
and gives the followings in the end:
F1 = f(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5);
F2 = f(p1,q1,p2,q2,p3,q3,p4,q4,p5,q5);
It would be nice to have the possibility to define multiple patterns for a zero-dimensional table. To avoid syntactic problems, in the following I would use
Define <zero-dimensional table> = <rhs>
, instead ofTable
andFill
, but the meaning should be clear.I would expect FORM automatically tries to apply
and gives the followings in the end: