Suggestion for EXECON.
12-17-2014, 12:51 PM (This post was last modified: 12-17-2014 01:06 PM by Snorre.)
Post: #21
 Snorre Member Posts: 101 Joined: Dec 2013
RE: Sugdestion for EXECON.
(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)}.
 « 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)