@jjmerelo
|
JMERELO@cpan.org
object MaxOnes extends Function1[Vector[Boolean],Double]
with Fitness[Vector[Boolean],Double] {
def Fitness( ev: Vector[Boolean]):Double =
ev.foldRight(0.0)((a:Boolean,b:Double)
=> if (a == true) b+1 else b )
def apply(v1: Vector[Boolean]): Double = Fitness( v1 )
}
onemax :: Seq Bool -> Int
onemax v =
Data.Foldable.foldl (\y -> (\x -> if x then y+1 else y)) 0 v
github.com/JJ/prog21