Enumerating the List of `nPr` (n Permute r) objects I have been using MATLAB for a particular project, and have seemed to find a function that may or may not exist. This question isn't MATLAB specific, more algorithm specific. 

I have a list of 12 items, indexed from 1 to 12. I want to be able to create a list of all possible permutations of these 12 items where I only want to select 6 of them per entry. 

Here is a reference to what nPr is for those unfamiliar.

In MATLAB, there is a function called perms(A) such that it calculates nPn where n = A.length. However what I am looking for is nPr where n = 12 and r = 6. Is there a way to either


Exploit the perms function such that it does nPn such that n = 6, but in a way that it actually calculates nPr where n = 12 and r = 6.
Write a recursive algorithm to replace the perms(A) function and create a perms(A,r) function?


Any pointers or tips would be much appreciated and helpful.
This is more of a MATLAB specific answer


  arrayfun(perms,nchoosek(A,r))


*Think of this as conceptual answer, because I have have been away from MATLAB and can't test it right now.

In other words,


get unordered combinations of elements in A, taken r at a time. using nchoosek.
get ordered combinations (with perms) of each unordered combinations. Applying a function to each element of a list can be done via arrayfun.