You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
currently, Base.Iterators.partition accepts an argument n which specifies the length of the disjoint subsets. i frequently find i would rather specify the number of disjoint subsets. has this been considered before? a similar interface-design issue exists with range(start, stop, length) and range(start, stop, step).
i actually already have some code that does this via a new iterator. and i was about to submit a PR to IterTools.
but i think a new method to Base.Iterators.partition might make more sense.
here is the docstring showing the API of what i currently have:
"""
split(xs, n)
Group values of xs into n disjoint sets. The sets will have identical
lengths if length(xs) is evenly divisible by n, otherwise they will be
approximately similar.
the existing partition API could be changed to partition(collection; n, l), where only one of the two keyword arguments would be specified, one acting as the old second positional argument, and the other specifying the desired number of disjoint sets.
should i stick with IterTools or extend Base? or neither? thanks!
The text was updated successfully, but these errors were encountered:
But unlike the present method, this one won't work for things like itr = (i for i in 1:10 if rand()>0.5) for which haslength(itr) == false. Perhaps unlike every other method in Iterators. Does that mean it should collect first in such cases? Or not live in Iterators? Or just give an error?
currently,
Base.Iterators.partition
accepts an argumentn
which specifies the length of the disjoint subsets. i frequently find i would rather specify the number of disjoint subsets. has this been considered before? a similar interface-design issue exists withrange(start, stop, length)
andrange(start, stop, step)
.i actually already have some code that does this via a new iterator. and i was about to submit a PR to IterTools.
but i think a new method to
Base.Iterators.partition
might make more sense.here is the docstring showing the API of what i currently have:
"""
split(xs, n)
Group values of
xs
inton
disjoint sets. The sets will have identicallengths if
length(xs)
is evenly divisible byn
, otherwise they will beapproximately similar.
See also:
partition
."""
the existing partition API could be changed to
partition(collection; n, l)
, where only one of the two keyword arguments would be specified, one acting as the old second positional argument, and the other specifying the desired number of disjoint sets.should i stick with IterTools or extend Base? or neither? thanks!
The text was updated successfully, but these errors were encountered: