slavapestov/factor — pull request #740 by jonenst (2012-10-28 14:02:09+00:00)
Title: change clump when the group size is greater than the sequence length

Currently, the docs say that clump throws an error, but it doesn't. It returns an empty sequence. This makes it return the original sequence instead. It's better than the previous behavior.
To me, it also seems better than throwing an error (the original advertised behavior)..

However, the implementation can be improved because it checks for the length of the underlying sequence and computes the min for every group@ call, so for every index in the case of clump. For non re-sizable sequences, we could change the size of the groups at the creation of the clumps because { 1 2 } 3 clump and { 1 2 } 2 clump are the same. For re-sizable sequences, we could at least look at the length of the sequence once for all indices in the case of clump.
Is this optimization worth the extra complexity ?