in reply to Re: Subsets and adjacent values
in thread Subsets and adjacent values

There is a little confusion of terms going on here. Mathematically a set is an un-ordered collection. However, the powerset() routine in Data::PowerSet returns arrays which are ordered.

What powerset() is really doing is producing all the sub-sequences (with gaps between elements allowed) of the input sequence. If your input sequence contains distinct elements, then you can think of it as being a set and think of all of the generated sub-sequences as subsets. That is, there is a correspondence between a sequence of distinct elements and the set consisting of those elements.

So, the powerset() routine can be used to produce either 1) all the sub-sequences of a given sequence or 2) all the subsets of a given set.

Replies are listed 'Best First'.
Re^3: Subsets and adjacent values
by blazar (Canon) on May 30, 2008 at 18:55 UTC

    I personally believe all this is evident and obvious, but... I can't understand why you're telling me! I knew. Still stands the point I tried to make to the OP: namely, that he should carefully choose the frameset for the problem. He reasoned in terms of sets: that these are "implemented" (please bear with me being slightly sloppy wrt terminology) with lists in the referenced module was considered a side effect to be used afterwards, which suggested him an overkill of an algorithm, while if he had resoned in terms of lists in the first place, he would have probably chosen a saner one to start with.

    --
    If you can't understand the incipit, then please check the IPB Campaign.
      Sorry, by placing my reply under your node I didn't mean to imply that you were confused. It just seemed like a good opportunity to bring up the fact that powerset() can be used for either sequences or sets.