Skip to content

Commit

Permalink
Make Permutations serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jun 28, 2024
1 parent f5af3bd commit 5d6277d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/metamorphose.Permutation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import scala.collection.mutable.BitSet
import scala.annotation.*

import contingency.*
import rudiments.*
import anticipation.*

object Permutation:

Expand Down Expand Up @@ -50,6 +52,8 @@ case class Permutation(factoradic: Factoradic):
lazy val lehmer: List[Int] = factoradic.expand
lazy val expansion: List[Int] = unsafely(apply[Int](List.range(0, lehmer.length)))

def bytes: Bytes = unsafely(factoradic.number.toByteArray.immutable)

def apply(n: Int): Int = expansion(n)

def apply[ElementType](sequence: List[ElementType]): List[ElementType] raises PermutationError =
Expand Down
3 changes: 3 additions & 0 deletions src/core/soundness+metamorphose-core.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package soundness

export metamorphose.{Factoradic, Factorial, Permutation, PermutationError}

0 comments on commit 5d6277d

Please sign in to comment.