Partition representations: Difference between revisions

Jump to navigation Jump to search
→‎Target indices: Add BQN link
m (→‎Definitions: Partitions can't be empty)
(→‎Target indices: Add BQN link)
(2 intermediate revisions by 2 users not shown)
Line 53: Line 53:
└──┴────┴─┘
└──┴────┴─┘
</source>
</source>
A more rigorous approach is to allow the left argument to specify the [[index]] of the division to which the corresponding element belongs. In order for this to produce a partition, the left argument must be a vector of non-decreasing non-negative integers (as with the division endpoint representation). Then for a left argument <source lang=apl inline>l</source> the number of divisions is <source lang=apl inline>⊃⌽l</source>.
A more rigorous approach is to allow the left argument to specify the [[index]] of the division to which the corresponding element belongs. In order for this to produce a partition, the left argument must be a vector of non-decreasing non-negative integers (as with the division endpoint representation). Then for a left argument <source lang=apl inline>l</source> the number of divisions is <source lang=apl inline>⊃⌽l</source>. BQN's [[Group (BQN)|Group]] uses an extension of this representation.
<source lang=apl>
<source lang=apl>
       1 1 3 3 3 3 6 part 'abcdefg'
       1 1 3 3 3 3 6 part 'abcdefg'
Line 116: Line 116:
Because it interleaves elements from a vector with dividers, partitioning is closely related to the [[Mesh]] operation. In fact, a partition can be used to produce a mesh by prepending an element to each division and [[Raze]]ing:
Because it interleaves elements from a vector with dividers, partitioning is closely related to the [[Mesh]] operation. In fact, a partition can be used to produce a mesh by prepending an element to each division and [[Raze]]ing:
<source lang=apl>
<source lang=apl>
       ⊢P
       ⎕←P
┌┬──┬┬────┬┬┬─┐
┌┬──┬┬────┬┬┬─┐
││ab││cdef│││g│
││ab││cdef│││g│
Line 145: Line 145:
</source>
</source>
In the above functions, the only difference in code is exchanging 0 and 1, and the only difference in output is an extra trailing 0 when computed from the division lengths. The mesh representation makes the partition representation duality especially clear, as the dual representation can be obtained simply by [[Not|negating]] the mesh vector.
In the above functions, the only difference in code is exchanging 0 and 1, and the only difference in output is an extra trailing 0 when computed from the division lengths. The mesh representation makes the partition representation duality especially clear, as the dual representation can be obtained simply by [[Not|negating]] the mesh vector.
[[Category:Essays]]

Navigation menu