Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
43
Task/Polymorphism/Ela/polymorphism-1.ela
Normal file
43
Task/Polymorphism/Ela/polymorphism-1.ela
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
type Point = Point x y
|
||||
|
||||
instance Show Point where
|
||||
show (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" || nm == "y"
|
||||
|
||||
pointX = flip Point 0
|
||||
|
||||
pointY = Point 0
|
||||
|
||||
pointEmpty = Point 0 0
|
||||
|
||||
type Circle = Circle x y z
|
||||
|
||||
instance Show Circle where
|
||||
show (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" || nm == "y" || 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
|
||||
2
Task/Polymorphism/Ela/polymorphism-2.ela
Normal file
2
Task/Polymorphism/Ela/polymorphism-2.ela
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
c = circleX 12
|
||||
c.x //Evaluates to 12
|
||||
Loading…
Add table
Add a link
Reference in a new issue