10-04-2015, 02:44 AM
Define a couple of binary cas-lam functions:
vadd := "(A,B)->BEGIN return; A+B; END" <-- No SEMI VERY IMPORTANT
vmpy:="(A,B)->BEGIN return; A*B; END"
Then make a cas pgm which applies an arbitrary input binary funtion to two list
arguments:
#cas
toboth(f,l1,l2) :=
BEGIN
LOCAL K;
FOR K FROM 1 TO SIZE(l1) DO
L3(K) := expr(f)(l1(K),l2(K)); <-- this would never compile in ppl
END;
L3;
END;
#end
Then call our function with each of our "lamdas"
toboth(vmpy,{1,2,3},{8,6,7}) -> {8,12,21}
toboth(vadd,{1,2,3},{8,6,7}) -> {9,8,10}
Doesn work if we send expr (lam) first. Seems to need string form.
Not quite lambda but its pretty darn close.
The problem with using Programs (name):=string is that the target cant compile if the pgm doesn exist until runtime. I suppose you could compile
with a dummy then change it at runtime. But....
vadd := "(A,B)->BEGIN return; A+B; END" <-- No SEMI VERY IMPORTANT
vmpy:="(A,B)->BEGIN return; A*B; END"
Then make a cas pgm which applies an arbitrary input binary funtion to two list
arguments:
#cas
toboth(f,l1,l2) :=
BEGIN
LOCAL K;
FOR K FROM 1 TO SIZE(l1) DO
L3(K) := expr(f)(l1(K),l2(K)); <-- this would never compile in ppl
END;
L3;
END;
#end
Then call our function with each of our "lamdas"
toboth(vmpy,{1,2,3},{8,6,7}) -> {8,12,21}
toboth(vadd,{1,2,3},{8,6,7}) -> {9,8,10}
Doesn work if we send expr (lam) first. Seems to need string form.
Not quite lambda but its pretty darn close.
The problem with using Programs (name):=string is that the target cant compile if the pgm doesn exist until runtime. I suppose you could compile
with a dummy then change it at runtime. But....