You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
genCnj :: Int -> Gen Form
genCnj i = do n <- choose(2, i)
f <- vectorOf n (genForm (i `div` n))
return (Cnj f)
Too complicated and to restricted. Simpler solution by using n of sized.
So an improvment will be
genCnj :: Int -> Gen Form
genCnj n = do
f <- vectorOf n (genForm (n `div` 2))
return (Cnj f)
And
-- Exercise 4 - Erik van Scharrenburg
instance Arbitrary Form where
arbitrary = sized genForm
genForm :: Int -> Gen Form
genForm 0 = genProp
genForm 1 = genProp
genForm 2 = genProp
genForm i = oneof [genNeg (i - 1),
genCnj (i - 1),
genDsj (i - 1),
genImpl (i - 1),
genEquiv (i - 1)]
genProp :: Gen Form
Better
-- Exercise 4 - Erik van Scharrenburg
instance Arbitrary Form where
arbitrary = sized genForm
genForm :: Int -> Gen Form
genForm 0 = genProp
genForm n = oneof [genNeg n
genCnj n,
genDsj n,
genImpl n,
genEquiv n]
genProp :: Gen Form
Well done (=9)
The text was updated successfully, but these errors were encountered:
Too complicated and to restricted. Simpler solution by using
n
ofsized
.So an improvment will be
And
Better
Well done (=9)
The text was updated successfully, but these errors were encountered: