Items tagged with list list Tagged Items Feed

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

I wrote the following code inside a code region in order to implement a scalar product for lists:

m:= module() option package; export `*`;
    `*`:= proc( a::list, b::list) option overload;
        return add(i, i  in zip((x, y)-> x*y, a, b));
    end proc;    
end module;
l1:=[1,2,3,4];
l2:=[4,1,0,5];
with(m);
l1*l2;

when i run the code I sometimes get the desired result ->26

but sometimes I get

I don't have any clue, where this weird behaviour comes from.

Any help would be greatly appreciated.

 

such as the list [[0,2],[3,-2],[7,6],.....,[x,y]]

and change to piecewise 

Write a procedure which inverts a given 2x2 matrix ie
Given a list of 4 numbers (a,b,c,d) return numbers (x,yz,w) such that
Matrix(a,b,c,d)(Matrix(x,y,z,w)) =Identity matrix

I have a nested list a := [[1,2,3],[4,5,6],[7,8,9]]: and would like to apply a function f to the 1st elements in nested list, e.g. [[f(1),2,3],[f(4),5,6],[f(7),8,9]]. How can I achieve this?

Thanks in advance.

Cumulative list...

January 11 2014 erik10 341

Dear Maple users

My question is probably simple, but I can't seem to figure out how to do it in a smart way way without using procedures: My task is to create a cumulative list from a list. Ex: From [3,-2,5,1,10,7] I want to create the list [3,1,6,7,17,24]. Every entrance in the new list is the sum of the previous ones including the actual entrance. The Statistics package contain a command named CumulativeSum, but unfortunately a list is not returned ... I hope someone can help doing it is a simple way.

Regards,

Erik

I have a list of the structure like

['true', ['true','false'], ['true',['false','true'],'false'],...]

Is it possible to complete 'and' operation with all elements of list without knowing exact structure of list?

I have to make a plot for experimental data where x corresponds to time and y is the concentration. So I loaded the values in two lists, ran fit to least squares and got the best fitting curve (it's linear). However, the line has to start at (0,0). How can I Maple to do that for me?

I have created a simple proc to return true or false depending on the value in a list of values.  now i would like to filter out the falses and return the actual value that is true from the list.

 

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