Advertisement
tinyevil

Untitled

Jan 13th, 2019
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. struct Point[T]{
  2. var x y: T;
  3. }
  4.  
  5. implementation Point{
  6. function Origin(): Point[T]
  7. where 0 :> T
  8. {
  9. return Self{x: 0, y: 0};
  10. }
  11.  
  12. instance Add[Self, Self, Self]
  13. where valueof(T) + valueof(T) : T
  14. {
  15. function add(a b: Self){
  16. return Self{
  17. x: a.x + b.x,
  18. y: a.y + b.y
  19. };
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement