Go to Google Groups Home    comp.soft-sys.math.maple
Re: Maple: extracting data from sets of sets

Ray Vickson <rgvick...@shaw.ca>

On Feb 27, 12:53 pm, Axel Vogt <&nore...@axelvogt.de> wrote:

> Roger Kopler wrote:
> > Thanks!!!

> Be aware that if you are working with sets, there
> is no guarantee on ordering. So do not assume that
> positions match in the result and X (sets do not
> have an ordering, lists do).

However, you can give impose an ordering (but not controlled,
initially); then that ordering remains in force throughout the rest of
the session:

Y:=[seq(i,i in X)]; <----------- Note the '[ ]'
  Y := [{a = 3, b = -3}, {a = 2, b = 2}, {a = 0, b = 3},

        {a = 2, b = -4}, {b = 2, a = 0}, {a = 2, b = 0}]

[seq( eval(f(a,b),xi), xi in Y)]; <---------Note the '[ ]'
               1/2         1/2     1/2         1/2     1/2
       [3 - 3 2   , 2 + 2 2   , 3 2   , 2 - 4 2   , 2 2   , 2]

Here, the ordering in Y is whatever ordering Maple decided to use for
X when the call was made. You can't control it, but you can at least
be guaranteed the order remains unchanged from now on (in Y, that is,
not in X). If you don't use [ ] in this evaluation, Maple may again
write the results in some random order:

{seq( eval(f(a,b),xi), xi in Y)}; <----- Note the '{ }'
                  1/2         1/2         1/2     1/2     1/2
       {2, 3 - 3 2   , 2 + 2 2   , 2 - 4 2   , 2 2   , 3 2   }

So, here you don't know which element of Y gives the entry f(a,b) =
2!

Note: sets do not have repeated elements, so if you wanted to have two
or more identical entries in X you could not do it: they would appear
only once. Lists and sequences can, however, have repetitions.

R.G. Vickson.