HI all!

Yes. It would make sense. The output could be a three-dimensional array of set-partition, set and set-item.

This item in the array:

1 0 0 0 0
0 1 0 0 0
0 0 1 1 1

would then describe

(0)(1)(2 3 4)

The items could also be transposed(set-partition, set-item, set):

1 0 0
0 1 0
0 0 1
0 0 1
0 0 1

I don't know which is best. I prefer the first.

We could move items between sets with cray-code-like techniques.

It would be easy to rewrite parRuskey to handle booleans. Bitmaps would be more tricky.

Cheers,

Erling Hellenäs

Den 2017-11-14 kl. 07:37, skrev 'Skip Cave' via Programming:
This thread has been an interesting exploration of the many ways to
implement
"all combinations of y unique items, x items at a time". I like the idea
that these
combination verbs produce a bitmap that can be used to select from a list
of
unique items to produce the final combinations.

Does it make sense to use this same technique to generate a partition verb
which produces a bitmap, which can then be used to partition a list of
unique items
showing "all ways to partition y objects into x partitions"?
Would the combination verbs developed previously help simplify the
partition verb?

Partition verb rules:
1. The par verb is a dyadic verb: x par y where x is the number of
partitions (boxes)
& y is the number of unique items to be partitioned (boxed).

2. The par verb should generate all the ways that y items can be
partitioned into
x partitions (containers). Each row in the output will show a different
allocation
of the y items.

3. The partition verb should produce a partitioned bitmap which can be used
to
select items from the list y, and place them in the appropriate partitions.

4. Every partition must have at least one item in it. (no empty partitions)

5. Every item can only appear once in each partition trial (row).

6. Re-ordering the items in a single partition does not create a new unique
partition.

5. Re-ordering partitions where the same items are still in each partition,
is not a new
partition trial.

The result of x par y should be a bitmap such that (x par y) f list will
show
all the possible ways to partition y items in x partitions

     2 par 3

┌─────┬─────┐

│1 1 0 │0 0 1 │

├─────┼─────┤

│1 0 1 │0 1 0 │

├─────┼─────┤

│0 1 1 │1 0 0 │

└─────┴─────┘


NB. now what is 'f':


    (2 par 3) f 'abc'

┌──┬─┐

│ab│c│

├──┼─┤

│ac│b│

├──┼─┤

│bc│a│

└──┴─┘


Skip

Skip Cave
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to