Recursive programs in XCAS.
03-01-2017, 04:46 AM (This post was last modified: 03-01-2017 05:28 AM by Han.)
Post: #7
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: Recursive programs in XCAS.
Here's a CAS version that works on the Prime. Notice the upper-case MAKELIST command (which is different from the lower-case makelist command). MAKELIST is a non-CAS command. This was a quick conversion from non-CAS to CAS (which does not support CASE as far as I can tell; it does have CASES, though, which seems to be the same as piecewise). You can make the code much cleaner using several return() calls.

PHP Code:
#cascomboset(s,n):=BEGINlocal l;local sl;local tl;local k;local j;local m;local t;m:=size(s);l:={};sl:={};tl:={};if n==m then l:={s}; else  if n==1 then l:=MAKELIST({s(X)},X,1,m); else     if n>m then l:={}; else      for k from 2 to m-n+2 do        sl:=sub(s,k,m);         tl:=comboset(sl,n-1);        for j from 1 to size(tl) do          tl[j]:=concat({s[k-1]},tl[j]);        end;        l:=concat(l,tl);       end;    end;  end;end;return(l);END;#end

Graph 3D | QPI | SolveSys
 « Next Oldest | Next Newest »

 Messages In This Thread Recursive programs in XCAS. - John P - 02-12-2017, 12:22 AM RE: Recursive programs in XCAS. - Han - 02-12-2017, 01:41 AM RE: Recursive programs in XCAS. - John P - 02-12-2017, 02:08 AM RE: Recursive programs in XCAS. - John P - 02-12-2017, 02:32 AM RE: Recursive programs in XCAS. - Han - 02-12-2017, 02:52 AM RE: Recursive programs in XCAS. - Han - 02-12-2017, 04:06 AM RE: Recursive programs in XCAS. - Han - 03-01-2017 04:46 AM RE: Recursive programs in XCAS. - Han - 03-01-2017, 04:49 AM

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