Post Reply 
in search of LAMBA functions
10-04-2015, 02:44 AM
Post: #1
in search of LAMBA functions
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....

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
in search of LAMBA functions - ji3m - 10-04-2015 02:44 AM



User(s) browsing this thread: 1 Guest(s)