Items tagged with list list Tagged Items Feed

i want to use dictionary or hashtable in maple

the key are a function, value are a list of things

 

how to do?

a:=Vector([2,3,4,5]);

select[flatten](x->x>=3,a);

This returns a Vector that satisfies the above condition. What's the most efficient way to get the indices of those entries?

For example, a list l:=[2,3,4] that correspond to the a[l] entries that satisfies the above condition.

l:=[2,3,4];

a[l]; # gives the same answer

 

Thanks,

 

casper

restart;

Vector([a, b]);  <a, b>;  # Identical results

a:=[1, 2]:  b:=[3, 4]:

Vector([a, b]), <a, b>;   # Different results. Why?

 

 

 

The problem is when initializing a Matrix with a list of strings. The worksheet excerpt below shows the normal behavior using a list of integers to initialize a square matrix: the successive list elements fill the matrix by rows.

Then trying the exact same thing with a list of strings instead of integers gives an error message!
This is not right. While it is an odd and likely rare problem, it would be better fixed.

x := [i $ i=1..25];
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
Matrix(5,5,x);
Matrix(5,5,[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) 

y := map(convert,x,string);
["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25"]
Matrix(5,5,y);
Error, (in Matrix) initializer defines more columns (25) than column dimension parameter specifies (5)

My problem is i am working with a very large randomly generated output, generated using maple's builtin in random generating functions. I have the output which i want to investigate but i want to be able to reproduce this result when i save and close the worksheet. Since the list of generators is very long copy pasting is not very nice and i donot know the seed of these generaters. I want to ask if i can store the values in variable in the worksheet so that when i open the worksheet i can get the same random generates stored in the variable.

Hi,

I would like to compute the elements of the permutation group, let us say S10 or S20.

Is there any method to compute all the elements.

And can we make a list of the tranposition and cycles.

Many thinks.

 

Is it possible to generate a list of values for a function in the form of an ordered pair, like

a cartesian plane, i.e. ( x, f(x) )? And how can I plot a graph with this output?

thanks in advance.

the sequence is non-decreasing up to some point after which it is non-increasing. Note that i can be 1 or n. A constant sequence is considered to be unimodal.

Examples of unimodal lists:

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

 

Examples of lists that are not unimodal:

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

 

i don't have a clue

Hi, with a list

l:=[1,1,1,2,3,3,4];

What's the best way to get the index(s) for the values equal to '1'?

Say for x=1, we want

[1,2,3]

for x=2, we want

[4]

ect.

 

Say I have this list,

tmp:=[[0, 1, 2], [1, 0, 2], [1, 1, 2], [1, 2, 0]];

and the sums of each element (list),

map(x->convert(x,`+`),tmp);

 

How do I quickly pickup the elements, where they sum to 3? Like this:

wanttohave:=[[0, 1, 2], [1, 0, 2],  [1, 2, 0]];

Thanks,

Please i don't want to convert from list to set then apply set minus and convert back because it loses its order and repititions.

 

so i want something that can for example do the following:

list_minus([1,2,4,6,2,1,3,6,2],[7,4,2,5,2]) = [1,6,1,3,6,2]

so it removes repititions from left and order is retained.

Hi all,

 

Say I have some list like this,

tmp:=[[0, 0, 1], [0, 1, 0], [0, 1, 1], [0, 1, 2], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2, 0]];

 

And I have worked out some probabilities for each of them, a,b,c,d, ect.

I want to print them like this

Pr( 001 ) = 1

Pr( 010 ) = 1-phi[2]+phi[2]*(1-p[3])*(1-phi[3])

Pr( 011 ) = phi[2]*p[3]*(1-phi[3])

and so on.

I there a way to do that?

The probabilities can be extracted from a Vector. I have no problem to print them.

I dont know how to convert the 0,1,2 into the desired format as shown above.

 

This is the best I can do.

 

Also, is it possible to convert all the subscripte [] to _ when printing the output?

and get ride of all * as well.

Thanks,

 

casperyc

 

assume input 0.567

how to get a list [5, 6, 7] or [5;6;7]?

m:=proc(n::list)
local N, S, i:
N:=nops(n);
S:={};
for i from 1 to N do
if n[i]=1 then do
S:=S union {i}; break; od; fi; od;
for i from 1 to N do
if n[i]=0 then do
S:=S union {}; break; od; fi; od;
end proc;

 

the procedure works if the last member of a list is 0, for example 

m(1,0,1,0); 

returns {1,3}

 

but if it ends in 1, nothing gets returned, example: m(1,0,1);

I can also get it to work the other way around, where it'll return the set if the list ends in 1 but not zero. I need it to work for both.

okay so im quite confused, im trying to write a procedure that prints the orbit of a 2x2 matrix through a given list of points.  our arguments should be a a (2x2) matrix, a list L of points represented by 2 vectors, ie (2x1) matrices and a natural number N. Returnvalue : NULL

a side effect should be to 

A^i.L[j] for i = 0 ... N and j = 1 ... nops(L)

thus, an example, if the proc is called P, then 

P(Matrix([[0,-1],[1,0]]),[Matrix([[1],[1]]),Matrix([[1],[0]])],2) 

should plot the points  

(1,1) ,(-1,1) , (-1,-1)  for the 1st point  and 

(1,0)  ,(0,1) , (-1,0) for the second

thanks for any help in advance

1 2 3 4 5 6 7 Last Page 1 of 45