Hi Don,
At 06:35 PM 8/26/02 +0100, you wrote:
>Is there a way to access the elements of a set similar to accessing the
>elements of a vector or matrix? The POWER_SET function is very powerful,
>but it cannot be used in programming because there is no way to access the
>subsets or elements of sets. For instance, I may want to know the
>combinations of four things taken two at a time and perform some
>calculations based on those combinations. POWER_SET(s,n) can tell me what
>the combinations are, but I can't do anything with them.
>
>It would be nice if this ability was added to the next version of DERIVE.
>
>Don PHillips
>[log in to unmask]
>
Strictly speaking a set is not ordered so the usual functions to access
elements of a vector don't make sense. OTOH, Derive could refer to the
internal ordering of the elements in a set and there is even one function,
namely REST(), that already does so. It's really a pity that FIRST()
doesn't work in this way too, because this would help a lot. In some
situations FIRST() can be replaced by MIN() though. Also very helpful might
be the functions
LIST_TO_SET(v):=MAP_LIST(v sub i,i,{1,..,dimv})
and SORT() for the conversions of lists to sets and vize versa, which have
been posted on this forum several times. (I dont' mind repeating them for
you and all the newcomers though!)
Cheers,
Johann
|