tvectorspace.nim 326 B

1234567891011121314151617181920
  1. discard """
  2. joinable: false
  3. """
  4. type VectorSpace[K] = concept x, y
  5. x + y is type(x)
  6. zero(type(x)) is type(x)
  7. -x is type(x)
  8. x - y is type(x)
  9. var k: K
  10. k * x is type(x)
  11. proc zero(T: typedesc): T = 0
  12. static:
  13. assert float is VectorSpace[float]
  14. # assert float is VectorSpace[int]
  15. # assert int is VectorSpace