DennisMitchell / jellylanguage

Jelly is a recreational programming language inspired by J.
MIT License
860 stars 47 forks source link

Add permutation indexing atoms #25

Closed jjallan closed 7 years ago

jjallan commented 7 years ago

Index into lexicographically sorted list of permutations, or find indexes of permutations without constructing the sorted lists. Worthy of note is the slightly odd monad, Œ?, which will find the shortest possible permutation of items [1,length] that would have such an index, but is useful since that range is (length-1)!+1 to length! inclusive. If one needs to find lower entries use the dyad with an integer (or range) instead. As an example 24Œ? will return the 24th permutation of four items [4,3,2,1], if you actually want the 24th permutation of more items do something like 24œ?7 to get [1,2,3,7,6,5,4].

DennisMitchell commented 7 years ago

Accepted and deployed. Thank you!