-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
118 additions
and
31 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
protocol Arithmetic { | ||
func add(#) -> #; | ||
func sub(#) -> #; | ||
add(#) -> #; | ||
sub(#) -> #; | ||
}; | ||
|
||
object Point: Arithmetic { | ||
p:(x:@ y:@); | ||
type Point(x:@ y:@) implements Arithmetic { | ||
init(q:(x:@ y:@)) -> Point { | ||
p.x = q.x; | ||
p.y = q.y; | ||
} | ||
x = q.x; | ||
y = q.y; | ||
}; | ||
add(q:Point) -> Point { | ||
Point(((p.x + q.x) (p.y + q.y))) | ||
new Point(((x + q.x) (y + q.y))); | ||
}; | ||
sub(q:Point) -> Point { | ||
Point(((p.x - q.x) (p.y - q.y))) | ||
new Point(((x - q.x) (y - q.y))); | ||
}; | ||
}; | ||
|
||
5; | ||
|
||
/*let origin:Point = (0 0); | ||
let vector:Point = (1 2); | ||
let origin:Point = new Point(0 0); | ||
let vector:Point = new Point(1 2); | ||
|
||
origin.add(vector) | ||
*/ |