Items tagged with list


This may sound like a dumb question, but i'm seeking a procedure to do it better.



with(combinat, setpartition) :
P := [$2..5] :

Tours := setpartition(P);M:=nops(Tours)

[[[5], [2, 3, 4]], [[2], [5], [3, 4]], [[3], [5], [2, 4]], [[4], [5], [2, 3]], [[2], [3], [4], [5]], [[2, 3, 4, 5]], [[2, 5], [3, 4]], [[2], [3, 4, 5]], [[2, 4], [3, 5]], [[3], [2, 4, 5]], [[2, 3], [4, 5]], [[4], [2, 3, 5]], [[3], [4], [2, 5]], [[2], [4], [3, 5]], [[2], [3], [4, 5]]]





number of elements in each 'group'


2, 3, 3, 3, 4, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3



i need to add 1 to each 'subgroup' : These are the first two:


[[[1, 5], [1, 2, 3, 4]], [[1, 2], [1, 5], [1, 3, 4]]]



I need to add 1 to each 'subgroup' in a more automatic way.





To select a piece from a list, for example:


I want to get the list piece from second place to fifth place: [2,3,4,5].

Is there a function?


I have to generate a random list of 30 elements and i have two variables: s, which is a counter for all the list which have got at least a repetition and variable n, for each list who has not repeated values, as in the code below.

I don't understand why, when i sum s and m i get a value which is not 100, why?

for i by 1 to 100 do
		list:=RandomTools[Generate](list(integer(range = 1 .. 365), 30));
		if numelems(FindRepetitions(lista)) >= 1 then
		else		n:=n+1;
				end if;
				end do;


How can i convert each column of a matrix(30X10) in a list?

I have a list of univariate polynomials

P:=[x^2-7*x+10, x^2, x^2+2*x+1]

How do I get the gcd of all of these?

It doesn't like it when I do the following:




I have a list of sample values and I want to remove just one maybe two of them. 


How could I remove just one 25 from the list? 


I have a list of equations. I would like to display this list in column.
Problem : as each term of my list is an equation, i can not transform my list in a vector.
How can I do to display a list of equations in column ?

Thank you for your help.

Hi all, i have a problem someone help me.

Define per(f(a,b,c)) = {f(a,b,c), f(b,c,a), f(c,a,b)}. I want to write a function removePer() that removes the permutations, example:

ds := {a, b, a^2, b^2, c, c + 2a, a - b, c^2, a + 2b, b + 2c}

then removePer(ds) return {a, a^2, c + 2a, a - b} because per(a) = {a, b, c}, per(a^2)  = {a^2, b^2, c^2} and per(c+2a) ={a+2b, b+2c, c+a}. Note that removePer(ds) can return {b, a^2, c + 2a, a - b} or {c, a^2, c + 2a, a - b}, ...  but just one result.

ds := {ab, bc, a - b^2, b - c^2, a^2, c - a^2},

then removePer(ds) return {ab, a - b^2, a^2}.

Thank you very much.

Dear All

For six parameters, I have corresponding list of their values and there are eight values for every parameter. I need to put these values in a formula to obtain a list of output values. There are two formulas one for 'P' and next is for 'RL'. I have used value of 'P' to calculate value of 'RL'. There are some complex number too, for which I have used modulus and final value is calculated by using 'evalf', but this command is not returning proper values for list as required. But this command works fine when I use single value from every list to calculate RL.

The Maple sheet attached herewith.


I am new to Maple.

If i have a list (or a table) A:=[[1,2],[3,4],[5,6]

how can i split it into two lists B:=[1,3,5] and C:=[2,4,6] ? (all the 1st numbers in one list, and all 2nd numbers in another list).


I want to solve this equation and looking at the plot there are at least 3 solutions. I want the greatest/smallest negative solution. Unfortunately using solve with assumptions produces no results and solve without assumptions only finds two solutions.

Can you please help me?

#select greatest negative value from solution


expr:= ax*cos(lambda)+ay*sin(lambda)-(a+b*lambda)



ax:=1:ay:=2:a:=0.5:b:=0.25: #examplanatory values




assume(-2*Pi<lambda,lambda<0): #does not work


sol_lambda:=[solve(expr=0,lambda, useassumptions)];# returns empty list even though without assumption one solution is found

Warning, solutions may have been lost




sol_lambda:=[solve(expr=0,lambda)]; #returns only two solutions even though looking at the plot 3 are there

Warning, solve may be ignoring assumptions on the input variables.


Warning, solutions may have been lost


[2.190357220, -.2688724573]


sol_l_v:=evalb~(sol_lambda<~0); #dirty workaraound

[false, true]


sol_l_add:=[ListTools:-SearchAll(true,sol_l_v)] ; #this seems overly complicated




lambda:=sol_lambda[sol_l_add[-1]];  #to select the last entry




expr; #test








how to convert (a+b)^3 to a list [a+b, a+b, a+b]?

for example

(a+b)^2 to [a+b, a+b]

how to count how many terms or items are equal when compare two lists of polynomial terms when length of two list may not be equal

I have this lists and I have written a program to process these lists and produce only the lists that certisfy a certain condition. Instead of printing these lists, I want just the total number of the lists produced. How can I do these? The only thing I can think of now is to append the lists in an Array and get the number of elements in the array, but this will be very inefficient since I am looking at a very big number here.


Any help is appreciated,




I would like to thank everyone who takes their time to respond to posts on this page. I have another question.

I have about 11 trillion lists that are of the form A shown below. The lists ofcourse have more elements than A (about 50 elements). What I want is to compute this value I call f, and the moment this value is found to be 1, we stop, and if all the values of f are 0, then we print(A). Here is my code, which has a problem and doesn't give me the result I want. How do I modify this so that if any value of f=1, then we stop, elif no 1 is found, we print just one value for A and not for every 0 produced?

A := [[1, 2], [1, 7], [5, 6], [1, 6], [1, 9], [6, 5], [9, 1], [2, 1], [7, 1], [6, 1], [5, 6]]; n := 9;
for i to n do for j to n do for k to nops(A) do if [i, j] = A[k] then a := Search([i, j], A); b := Search([j, i], A); if a < b then f := `mod`(b-a, 2); if f = 1 then break else print(A) end if end if end if end do end do end do;

Presently what I am doing is to Append all values of f into an Array and check that 1 is not an element of that Array. This is however very inconvenient since my lists are huge, and they are many, and we do not have to cpompute all the values of f once we come across a 1. Other than this, is there a way I can make my program run faster? Any suggestions are welcomed.



1 2 3 4 5 Page 1 of 5