partition functions
Partitions are typically given by a boolean with 1's marking
the beginning or end of each partition. Partitions are also
sometimes given in terms of the lengths of each partition.
Verbs defined here assume that boolean 1's mark the beginning
of each partition - see comments at the end for examples of
end-partition verbs.
The verbs psum and psumscan illustrate definitions appropriate
for verbs that return scalar or non-scalar results, respectively.
utility used to build non-scalar partition functions:
e.g.
1 0 0 1 0 0 0 = firstones 1 1 0 1 1 1 0
0 0 1 0 1 = lastones 1 1 1 0 1
2 3 1 = lfp 1 0 1 0 0 1
1 1 0 1 0 0 1 = partition 1 9 9 4 4 4 9
0 0 0 1 2 2 3 = runindices 3 1 2 1
1 2 3 1 = runlengths 1 9 9 4 4 4 9
x=. 1 0 1 0 0 [ y=. 5 3 2 2 7
3 5 7 2 2 = x preverse y
3 5 2 2 7 = x psort y
8 11 = x psum y
5 8 2 4 11 = x psumscan y
Defined items