SHARE
TWEET

Untitled

tinyevil Jan 13th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top