conglomerate

20 Reputation

One Badge

13 years, 198 days

MaplePrimes Activity


These are replies submitted by conglomerate

I got it! I need to convert this false "list" (which is actually table) into real list!

yes yes yes! merci!!!

I got it! I need to convert this false "list" (which is actually table) into real list!

yes yes yes! merci!!!

hey Doug,

I  put a variable to guard the size in order not to make it out of bound. and it works now;
Now I have another problem
 

 I try to remove from the list a as long as i come across a same value in list b, i used " subsop", but it removes all the values in list a:

let me put it simple: in maple if I do


l := list(30);

l := [1, 2, 3];

l := subsop(1 = NULL, l)             

Then I print(l) the result is l:=[2,3]

However, if i do l := list(30); l[1] := 2; l[2] := 2; l[3] := 3; l[4] := 3; l[5] := 5; l[6] := 7

then I print l out it shows

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

and then after i do l := subsop(1 = NULL, l); print(l), it shows

() = ()

????? What I want is that I only want to take the first element off, but this removes all my values, how come???

it is a list, and why it shows table here?
thanks!

 

hey Doug,

I  put a variable to guard the size in order not to make it out of bound. and it works now;
Now I have another problem
 

 I try to remove from the list a as long as i come across a same value in list b, i used " subsop", but it removes all the values in list a:

let me put it simple: in maple if I do


l := list(30);

l := [1, 2, 3];

l := subsop(1 = NULL, l)             

Then I print(l) the result is l:=[2,3]

However, if i do l := list(30); l[1] := 2; l[2] := 2; l[3] := 3; l[4] := 3; l[5] := 5; l[6] := 7

then I print l out it shows

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

and then after i do l := subsop(1 = NULL, l); print(l), it shows

() = ()

????? What I want is that I only want to take the first element off, but this removes all my values, how come???

it is a list, and why it shows table here?
thanks!

 

hey Alec,

I got you. I need to put a variable to guard the size in order not to make it out of bound. and it works now;
Now I have another problem
In my real code( for a school's assignment) the two lists are obtained from 2 blocks of my other code instead of here I explicitly declared as a:=[2,2,3,3,3,5] and b:=[2,2,2,3,7].

what i did in my other blocks of code was:

I declared list a and list b after the execution of that blocks of code, if i try to print list a and list b out, I got:

table([1 = 2, 2 = 2, 3 = 3, 5 = 3, 4 = 3, 6 = 5]) and table([1 = 2, 2 = 2, 3 = 2, 5 = 7, 4 = 3]) respectively for a and b.

My problem is: I try to remove from the list a as long as i come across a same value in list b, i used " subsop", but it removes all the values in list a:

let me put it simple: in maple if I do


l := list(30);

l := [1, 2, 3];

l := subsop(1 = NULL, l)             

Then I print(l) the result is l:=[2,3]

However, if i do l := list(30); l[1] := 2; l[2] := 2; l[3] := 3; l[4] := 3; l[5] := 5; l[6] := 7

then I print l out it shows

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

and then after i do l := subsop(1 = NULL, l); print(l), it shows

() = ()

????? What I want is that I only want to take the first element off, but this removes all my values, how come???

it is a list, and why it shows table here?
thanks!

 

 





                                  

hey Alec,

I got you. I need to put a variable to guard the size in order not to make it out of bound. and it works now;
Now I have another problem
In my real code( for a school's assignment) the two lists are obtained from 2 blocks of my other code instead of here I explicitly declared as a:=[2,2,3,3,3,5] and b:=[2,2,2,3,7].

what i did in my other blocks of code was:

I declared list a and list b after the execution of that blocks of code, if i try to print list a and list b out, I got:

table([1 = 2, 2 = 2, 3 = 3, 5 = 3, 4 = 3, 6 = 5]) and table([1 = 2, 2 = 2, 3 = 2, 5 = 7, 4 = 3]) respectively for a and b.

My problem is: I try to remove from the list a as long as i come across a same value in list b, i used " subsop", but it removes all the values in list a:

let me put it simple: in maple if I do


l := list(30);

l := [1, 2, 3];

l := subsop(1 = NULL, l)             

Then I print(l) the result is l:=[2,3]

However, if i do l := list(30); l[1] := 2; l[2] := 2; l[3] := 3; l[4] := 3; l[5] := 5; l[6] := 7

then I print l out it shows

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

and then after i do l := subsop(1 = NULL, l); print(l), it shows

() = ()

????? What I want is that I only want to take the first element off, but this removes all my values, how come???

it is a list, and why it shows table here?
thanks!

 

 





                                  

Hi Doug, Thanks for your reply. They are not sets, but lists.

initially, a := [2, 2, 3, 3, 3, 5] and b := [2, 2, 2, 3, 7]
 The real problem of mine is that I want to get the smallest number of 2s 3s or whatever from 2 lists. In this case,

you can see that list a has two '2's and three '3's and one '5'; list b has three '2's, one '1' and one '7',

I want the final list a to be [2,2,3].

My algorithm is : compare b with a with the first element, say here it is 2, if there are the same, print it out, and remove this element (i.e. 2) from a, and break from the inner loop and begin to compare using the second element in b ;

if there are not the same, do no action. and so on... thus ideally eventually i should get [2,2,3], but my code stops after it compares the third '2' in b with [3,3,3,5] ( it already removes the first '2's) due to this subscript error.

In my real code, i didn't use index 10, but used the index not out of bound but i still got this error. Any thoughts?

Also, by the way, do you know how to check the dynamic size of a List??

Thanks!!

Hi Doug, Thanks for your reply. They are not sets, but lists.

initially, a := [2, 2, 3, 3, 3, 5] and b := [2, 2, 2, 3, 7]
 The real problem of mine is that I want to get the smallest number of 2s 3s or whatever from 2 lists. In this case,

you can see that list a has two '2's and three '3's and one '5'; list b has three '2's, one '1' and one '7',

I want the final list a to be [2,2,3].

My algorithm is : compare b with a with the first element, say here it is 2, if there are the same, print it out, and remove this element (i.e. 2) from a, and break from the inner loop and begin to compare using the second element in b ;

if there are not the same, do no action. and so on... thus ideally eventually i should get [2,2,3], but my code stops after it compares the third '2' in b with [3,3,3,5] ( it already removes the first '2's) due to this subscript error.

In my real code, i didn't use index 10, but used the index not out of bound but i still got this error. Any thoughts?

Also, by the way, do you know how to check the dynamic size of a List??

Thanks!!

Hi Alec,

Thanks for your reply.

initially, a := [2, 2, 3, 3, 3, 5] and b := [2, 2, 2, 3, 7]
 The real problem of mine is that I want to get the smallest number of 2s 3s or whatever from 2 lists. In this case, I want the final list a to be [2,2,3].

My algorithm is : compare b with a with the first element, say here it is 2, if there are the same, print it out, and remove this element (i.e. 2) from a, and break from the inner loop and begin to compare using the second element in b ;

if there are not the same, do no action. and so on... thus ideally eventually i should get [2,2,3], but my code stops after it compares the third '2' in b with [3,3,3,5] ( it already removes the first '2's). due to this subscript error.

In my real code, i didn't use index 10, but used the index not out of bound but i still got this error. Any thoughts?

Also, by the way, do you know how to check the size of a List??

Thanks!!

 

Hi Alec,

Thanks for your reply.

initially, a := [2, 2, 3, 3, 3, 5] and b := [2, 2, 2, 3, 7]
 The real problem of mine is that I want to get the smallest number of 2s 3s or whatever from 2 lists. In this case, I want the final list a to be [2,2,3].

My algorithm is : compare b with a with the first element, say here it is 2, if there are the same, print it out, and remove this element (i.e. 2) from a, and break from the inner loop and begin to compare using the second element in b ;

if there are not the same, do no action. and so on... thus ideally eventually i should get [2,2,3], but my code stops after it compares the third '2' in b with [3,3,3,5] ( it already removes the first '2's). due to this subscript error.

In my real code, i didn't use index 10, but used the index not out of bound but i still got this error. Any thoughts?

Also, by the way, do you know how to check the size of a List??

Thanks!!

 

Page 1 of 1