Last active
December 23, 2015 17:29
-
-
Save cronin101/6668695 to your computer and use it in GitHub Desktop.
Any example of how not to complete a first-year Haskell lab.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Informatics 1 - Functional Programming | |
| -- Lab Week Exercise | |
| -- | |
| -- Week 2 - due: Friday, Oct. 1, 5pm | |
| -- | |
| -- Insert your name and matriculation number here: | |
| -- Name: Willip Fodler | |
| -- Nr. : 01 | |
| import Test.QuickCheck | |
| import Control.Monad | |
| -- Exercise 3: | |
| double :: Int -> Int | |
| double = join (+) | |
| square :: Int -> Int | |
| square = join (*) | |
| -- Exercise 4: | |
| isTriple :: Int -> Int -> Int -> Bool | |
| isTriple = flip flip square . ((( . ) . (==)) . ) . ( . square) . (+) . square | |
| -- Exercise 5: | |
| leg1 :: Int -> Int -> Int | |
| leg1 = ( . square ) . (-) . square | |
| leg2 :: Int -> Int -> Int | |
| leg2 = (*) . (2 *) | |
| hyp :: Int -> Int -> Int | |
| hyp = ( . square ) . (+) . square | |
| -- Exercise 6: | |
| prop_triple :: Int -> Int -> Bool | |
| prop_triple = ap ( ap . ap (ap . (isTriple . ) . leg1) leg2) hyp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment