Mercurial > 12ws.info2
diff exercises/src/Exercise_8.hs @ 18:a899535b1674
week 8
author | Markus Kaiser <markus.kaiser@in.tum.de> |
---|---|
date | Fri, 07 Dec 2012 01:26:31 +0100 |
parents | |
children | 6688bf4a5836 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exercises/src/Exercise_8.hs Fri Dec 07 01:26:31 2012 +0100 @@ -0,0 +1,61 @@ +module Exercise_8 where +import Form +import Data.Ratio +import Test.QuickCheck + +{---------------------------------------------------------------------} +{- Aufgabe G8.1 -} + +f0 :: Fraction +f0 = Over 1 2 + +f1 :: Fraction +f1 = Over 7 5 + +norm :: Fraction -> Fraction +norm = undefined + + + +{---------------------------------------------------------------------} +{- Aufgabe G8.2 -} +-- siehe Exercise_8_Form.hs + +p0 :: Form +p0 = (Var "a" :&: Var "b") :|: (Not (Var "a") :&: Not (Var "b")) + + +p1 :: Form +p1 = ((Not $ Not $ Var "a") :|: (Not ((Var "b") :->: (Not (Var "c"))))) + + + +{---------------------------------------------------------------------} +{- Aufgabe G8.3 -} + +v0 = [("pizza", 7), ("cola", 2), ("apfel", 1)] + +a0 :: Arith +a0 = Add (Add (Mul (Const 3) (IVar "pizza")) (IVar "cola")) (IVar "apfel") + +data Arith = Add Arith Arith | Mul Arith Arith | Const Integer | IVar String deriving Show + + +evalArith :: [(String,Integer)] -> Arith -> Integer +evalArith = undefined + + + +{---------------------------------------------------------------------} +{- Aufgabe G8.4 -} + +mkTable :: Form -> [[String]] +mkTable = undefined + + +showTable :: Form -> String +showTable = unlines . map unwords . mkTable + + +printTable :: Form -> IO () +printTable = putStrLn . showTable \ No newline at end of file