comparison.km 741 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. export function is:[T]
  2. &(T,T) => Bool
  3. native 'is';
  4. type Op=
  5. [in T]
  6. &(T,T) => Bool;
  7. type Op<
  8. [in T]
  9. &(T,T) => Bool;
  10. export function !=:
  11. [T] { = : Op=[T] }
  12. &(T,T) => Bool
  13. &(a,b) => { not { = (a, b) } };
  14. export function >:
  15. [T] { < : Op<[T] }
  16. &(T,T) => Bool
  17. &(a,b) => { < (b, a) };
  18. export function <=:
  19. [T] { < : Op<[T] }
  20. &(T,T) => Bool
  21. &(a,b) => { not { < (b, a) } };
  22. export function >=:
  23. [T] { < : Op<[T] }
  24. &(T,T) => Bool
  25. &(a,b) => { not { < (a, b) } };
  26. export function min:
  27. [T] { < : Op<[T] }
  28. &(T,T) => T
  29. &(a,b) => (if { < (a, b) }: a, else: b);
  30. export function max:
  31. [T] { < : Op<[T] }
  32. &(T,T) => T
  33. &(a,b) => (if { < (b, a) }: a, else: b);