Jakub_Mec

15 Reputation

One Badge

0 years, 184 days

MaplePrimes Activity


These are questions asked by Jakub_Mec

Hello, 

I have a list of data {a,b,c,d} for which I need to create permutations without inbult function in Maple. The list of inputs is not fixed and it can contain aither one value or n-values. I was thinking about use of recursion in loops but it doesn't work as I was expected. Do you know please how to set a such recursive calculation with loops?
 

Result should be as follows for the list whole list range:

a+b

a+c

a+d

a+b+c

a+b+d
a+c+b
a+c+d

a+d+b

a+d+c

a+b+c+d

a+c+d+b

a+d+b+c

b+a

b+c

b+d

b+a+c

b+a+d

b+c+a

b+c+d

b+d+a

b+d+c

b+a+c+d

b+c+d+a

b+d+a+c

etc...

 

Comb1:=proc(S)
local G2::DataFrame,x,xs,i,j,T,k;

G2:=DataFrame([[]]);

if numelems(S)=0 then 
		return {}
		elif numelems(S)=1 then
			return {S}
		else 
			for i in seq(1..numelems(S))do
				for j in seq(1..numelems(S))do
					if i=j then
						next j
					end if;
			x:=S[j];
			xs:=S[i]+S[j];	

			#collect data into a dataframe
			G2:=Append(G2,DataSeries(<xs>),mode=row);

			#recursion
			for T in Comb1([xs]) do 
				for k in seq(1..numelems(S)) do
					if k=i or k=j then 
						next k
						end if;
				G2:=Append(G2,DataSeries(<[S[k]]+T>),mode=row);
				
					end do;
				end do;
			end do;
		end do;
	end if;
		
return G2;

end proc:

Comb1({a,b,c,d});

 

Hello, 

do you have an idea how could be filtered several values from dataframe? 
I have a dataframe called "TestData". I need to select rows from data frame which are equal to the list called "SelectionList". 

Thank you for a comment. 
 

Data:=<"LC1", "LC2", "LC3", "LC4", "LC5", "LC6", "LC7", "LC8", "LC9", "LC10", "LC11", "LC12", "LC13", "LC14", "LC15", "LC16", "LC17", "LC18", "LC19", "LC20">;
LoadValue2:=<10,15,100,82,18,89,25,84,46,18,79,12,0,28,147,15,86,444,18,65>;

TestData:=DataFrame(<Data|LoadValue2>,columns=[Case,Load]);

SelectionList:={"LC3", "LC4", "LC5", "LC6", "LC7", "LC8", "LC9"};

Page 1 of 1