Post Reply 
Recursive programs in XCAS.
03-01-2017, 04:49 AM (This post was last modified: 03-01-2017 05:12 AM by Han.)
Post: #8
RE: Recursive programs in XCAS.
Slightly more readable version.

EDIT: Also removed MAKELIST() call since PocketCAS probably does not have that version of the command.

PHP Code:
#cas
comboset(s,n):=
BEGIN
local 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}; return(l); end;
if 
n==1 then
    
for k from 1 to m do
        
l[k]:={s[k]};
    
end;
    return(
l);
end;
if 
n>m then l:={}; return(l); end;

for 
k from 2 to m-n+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;

return(
l);

END;
#end 

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


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)