Skip to content

Instantly share code, notes, and snippets.

@stupenrose
stupenrose / keybase.md
Created December 15, 2018 00:17
keybase made me do it

Keybase proof

I hereby claim:

  • I am stupenrose on github.
  • I am stupenrose (https://keybase.io/stupenrose) on keybase.
  • I have a public key ASCZ9kTEELNdtX_n9rfeIUxgDltTm8_uFhEk9m-Wieb6Hwo

To claim this, I am signing this object:

@stupenrose
stupenrose / Permutator.scala
Created September 11, 2014 03:50
A stream (lazy sequence) implementation of the 'lexical' algorithm for generating permutations
object Permutator {
/**
* http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permutations
*/
def permutate[T](parts:List[T])(implicit cmp: Ordering[T]):Stream[Seq[T]] = {
//sorting the sequence in (weakly) increasing order (which gives its lexicographically minimal permutation)
val start = parts.sorted
def remainder(parts:List[T]):Stream[Seq[T]] = {