randy3k/arrangements

How to use internal functions for some specialized case?

Opened this issue · 1 comments

Hello.

I need to calculate millions of times something like this:

x <- c("a", "b", "c", "d", "e", "f", "g","h", "i", "j")  # short vectors of letters
combinations(v=x, k=2)     # k is going to be always 2.

and

y <- 1:10    # short vectors of integers. And specifically sequences.
permutations(v=y)

How can directly use the internal specific functions for my case instead of the generic "permutations" and "combinations", which do many checks and eventually use some specialized function?
For example I've seen in the code there are functions with names such as "n_multiset_combinations".
My intention is to do it as fast as possible, without unnecesary checks because I know the inputs are going to be the proper ones.

The validation and dispatching are done in c. It should be only a little head over even if you do it a million times.