mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 13:15:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
731d8a72ad |
@@ -1,6 +1,6 @@
|
||||
package net.eagle0.common
|
||||
|
||||
import scala.annotation.{nowarn, tailrec}
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.SeqFactory
|
||||
|
||||
case class RandomState[+T](
|
||||
@@ -160,10 +160,9 @@ abstract class FunctionalRandom {
|
||||
)(
|
||||
f: (T, FunctionalRandom) => RandomState[S[U]]
|
||||
)(using xFactory: FACT): RandomState[S[U]] = {
|
||||
@nowarn def foldGen(rsU: RandomState[S[U]], t: T): RandomState[S[U]] =
|
||||
rsU.continue {
|
||||
case (us: S[U], fr: FunctionalRandom) =>
|
||||
f(t, fr).map(x => (us ++ x).asInstanceOf[S[U]])
|
||||
def foldGen(rsU: RandomState[S[U]], t: T): RandomState[S[U]] =
|
||||
rsU.continue { (us, fr) =>
|
||||
f(t, fr).map(x => xFactory.from(us ++ x))
|
||||
}
|
||||
FunctionalRandom.nextFoldLeft(
|
||||
seq,
|
||||
@@ -179,17 +178,16 @@ abstract class FunctionalRandom {
|
||||
nextFlatMapImpl[T, U, Vector, SeqFactory[Vector]](vec)(f)(using Vector)
|
||||
|
||||
private def nextMapImpl[T, U, S[X] <: Seq[X], FACT <: SeqFactory[S]](
|
||||
seq: Vector[T]
|
||||
seq: S[T]
|
||||
)(
|
||||
f: (T, FunctionalRandom) => RandomState[U]
|
||||
)(using xFactory: FACT): RandomState[S[U]] = {
|
||||
@nowarn def foldGen(
|
||||
def foldGen(
|
||||
rsU: RandomState[S[U]],
|
||||
t: T
|
||||
): RandomState[S[U]] =
|
||||
rsU.continue {
|
||||
case (us: S[U], fr: FunctionalRandom) =>
|
||||
f(t, fr).map(x => (us :+ x).asInstanceOf[S[U]])
|
||||
rsU.continue { (us, fr) =>
|
||||
f(t, fr).map(x => xFactory.from(us :+ x))
|
||||
}
|
||||
|
||||
FunctionalRandom.nextFoldLeft(seq, RandomState(xFactory.empty[U], this))(
|
||||
|
||||
Reference in New Issue
Block a user