Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. type True = {b};
  2. type False = {a};
  3.  
  4. type NOT<X> = X extends True ? False : True;
  5.  
  6. type AND<X,Y> = X extends True ? (Y extends True ? True : False) : False;
  7. type OR<X,Y> = X extends False ? (Y extends False ? False : True) : True;
  8.  
  9. let x: NOT<OR<NOT<True>,False>>; // x : True
  10.  
  11. type Num = any[];
  12.  
  13. type Eval<T extends Num> = T['length'];
  14.  
  15. type Zero = [];
  16.  
  17. type Succ<N extends Num> = Prepend<1,N>;
  18.  
  19. type Prepend<E, T extends any[]> = ((head: E, ...args: T) => any) extends ((...args: infer U) => any) ? U : T;
  20.  
  21. let y: Eval<Succ<Succ<Zero>>>; // y : 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement