Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment Lab 3 #1

Open
BertLisser opened this issue Oct 1, 2018 · 0 comments
Open

Comment Lab 3 #1

BertLisser opened this issue Oct 1, 2018 · 0 comments

Comments

@BertLisser
Copy link

BertLisser commented Oct 1, 2018

Exerc. 2

-- Assignment 2 (30 minutes)
testParse :: Form -> Bool
testParse form = show (head $ parse $ show form) == show form

can be simplified in

testParse :: Form -> Bool
testParse form = head $ parse $ show form) == form
Exerc. 4
-- Generator
createCnj :: Form -> Form -> Form
createCnj first second = Cnj [first, second]

createDsj :: Form -> Form -> Form
createDsj first second = Dsj [first, second]

formGen :: Int -> Gen Form
formGen n
  | n <= 0 = fmap Prop (choose (1,200))
  | n > 5 = formGen 5
  | otherwise = oneof [
      fmap Neg (formGen (n - 1)),                         -- Negation
      liftM2 createDsj (formGen (n-1) ) (formGen (n-2)),   -- Disjunctive
      liftM2 createCnj (formGen (n-1) ) (formGen (n-2)),   -- Conjunctive
      liftM2 Impl (formGen (n - 1)) (formGen (n - 2)),    -- Implication
      liftM2 Equiv (formGen (n - 1)) (formGen (n - 2))]   -- Equivalence

too restricted.
Cnj and Dsj with 0 or 1 arguments must be generated too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant