JuliaCollections / IterTools.jl

Common functional iterator patterns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New method for subsets of fixed size?

ettersi opened this issue · comments

I want to iterate over all unordered pairs in a collection A. Thanks to this package, the easiest way to do this is to use subsets(A,2), but this seems rather wasteful as it does not exploit that I know at compile time the size of the set. So I suggest to add a method subsets(xs,::Type{Val{k}}) which can do so.

I'd be happy to provide a PR, but I first wanted to check that there's a chance it will make it into this package. Also, it would be my first PR ever, so I would likely need some help along the way.

The new suggested way to do type constants would be to define subsets(xs, ::Val{k}) but yes this sounds like a good addition we would welcome.

Would it be acceptable to introduce a dependency on StaticArrays? Having a mutable statically sized data type would come in handy.

This was added in #13