Created
February 18, 2012 13:51
-
-
Save jakobw/1859340 to your computer and use it in GitHub Desktop.
1.2
This file contains 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
-- Probeklausur 1.2 | |
data N = Zero | S (N) deriving (Show) -- natürliche Zahlen | |
data Z = Z (N,N) deriving (Show) -- ganze Zahlen | |
class Rechnen a where | |
add :: a -> a -> a | |
instance Rechnen N where | |
add m Zero = m | |
add m (S (n)) = S (add m n) | |
instance Rechnen Z where | |
add (Z (m1, n1)) (Z (m2, n2)) = Z (add m1 m2, add n1 n2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment