Suggestion for EXECON.
12-17-2014, 06:05 PM
Post: #22
 John P Member Posts: 219 Joined: Dec 2013
RE: Sugdestion for EXECON.
(12-17-2014 12:51 PM)Snorre Wrote:
(12-17-2014 06:54 AM)parisse Wrote:  Yes, EXECON is more versatile. zip and apply work for 2 or 1 arg function. Otherwise just write a loop yourself if you need it in the CAS.

Hey, that sounds like a nice challenge.

My first purely(?) functional solution is (indentation+linebreaks for readability):
Code:
napply(fn, lsts):=   seq(     fn(seq(       map(lsts, lst->lst(k)) )),     k=1..min(map(lsts, length)) )

Usage:
a:={a1,a2,a3,a4}, b:={b1,b2,b3}, c:={c1,c2,c3,c4,c5}
abc:={a,b,c}
g(x,y,z):=x+y+z
napply(g,abc) returns the sequence a1+b1+c1, a2+b2+c2, a3+b3+c3
which could be made into a vector by putting brackets or a list by putting braces around it, e.g. {napply(g,abc)}.

Hello,
Yes it is. On the weekend I will write program to evaluate any function with any number of variables any number of times. For the example I was giving in this thread if you do something only one or two times on the command line in CAS or in HOME you do not need "EXECON" or "apply" etc. You can use the period "." to indicate element by element operation and you done. For ex. (l1.+l2)./((l3.-l2).^2) and pronto you have what you wanted, but to do that in prgm. in CAS it would be more complicated and I will do that on the weekend.

Cheers
 « Next Oldest | Next Newest »

 Messages In This Thread Suggestion for EXECON. - John P - 12-14-2014, 03:59 AM RE: Sugdestion for EXECON. - Snorre - 12-14-2014, 05:28 PM RE: Sugdestion for EXECON. - John P - 12-14-2014, 09:12 PM RE: Sugdestion for EXECON. - Marcus von Cube - 12-14-2014, 09:44 PM RE: Sugdestion for EXECON. - John P - 12-15-2014, 12:13 AM RE: Sugdestion for EXECON. - cyrille de brĂ©bisson - 12-15-2014, 10:09 AM RE: Sugdestion for EXECON. - John P - 12-15-2014, 10:57 AM RE: Sugdestion for EXECON. - Snorre - 12-15-2014, 12:31 PM RE: Sugdestion for EXECON. - John P - 12-15-2014, 12:57 PM RE: Sugdestion for EXECON. - DrD - 12-15-2014, 12:36 PM RE: Sugdestion for EXECON. - Didier Lachieze - 12-15-2014, 12:50 PM RE: Sugdestion for EXECON. - John P - 12-15-2014, 01:15 PM RE: Sugdestion for EXECON. - Marcus von Cube - 12-15-2014, 07:47 PM RE: Sugdestion for EXECON. - cyrille de brĂ©bisson - 12-16-2014, 06:58 AM RE: Sugdestion for EXECON. - John P - 12-16-2014, 07:55 AM RE: Sugdestion for EXECON. - parisse - 12-16-2014, 08:01 AM RE: Sugdestion for EXECON. - John P - 12-16-2014, 09:01 AM RE: Sugdestion for EXECON. - parisse - 12-16-2014, 09:48 AM RE: Sugdestion for EXECON. - John P - 12-16-2014, 09:36 PM RE: Sugdestion for EXECON. - parisse - 12-17-2014, 06:54 AM RE: Sugdestion for EXECON. - Snorre - 12-17-2014, 12:51 PM RE: Sugdestion for EXECON. - John P - 12-17-2014 06:05 PM RE: Sugdestion for EXECON. - parisse - 12-17-2014, 07:14 PM RE: Suggestion for EXECON. - John P - 12-19-2014, 10:47 PM

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