tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,45 @@
type Point = Point x y
instance Show Point where
showf _ (Point x y) = "Point " ++ (show x) ++ " " ++ (show y)
instance Name Point where
getField nm (Point x y)
| nm == "x" = x
| nm == "y" = y
| else = fail "Undefined name."
isField nm _ = nm == "x" or nm == "y"
pointX = flip Point 0
pointY = Point 0
pointEmpty = Point 0 0
type Circle = Circle x y z
instance Show Circle where
showf _ (Circle x y z) =
"Circle " ++ (show x) ++ " " ++ (show y) ++ " " ++ (show z)
instance Name Circle where
getField nm (Circle x y z)
| nm == "x" = x
| nm == "y" = y
| nm == "z" = z
| else = fail "Undefined name."
isField nm _ = nm == "x" or nm == "y" or nm == "z"
circleXZ = flip Circle 0
circleX x = Circle x 0 0
circleYZ = Circle 0
circleY y = Circle 0 y 0
circleZ = Circle 0 0
circleEmpty = Circle 0 0 0
circleX 1 2

View file

@ -0,0 +1,2 @@
c = circleX 12
c.x //Evaluates to 12