t12753.nim 573 B

1234567891011121314151617181920212223
  1. discard """
  2. output: '''
  3. (v: [(v: [0.0, 1.1]), (v: [2.2, 3.3])])
  4. (v: [(v: [0.0, 1.1]), (v: [2.2, 3.3])])
  5. '''
  6. """
  7. type
  8. V = object
  9. v:array[2,float]
  10. M = object
  11. v:array[2,V]
  12. var
  13. a = M(v:[ V(v:[0.0,1.0]), V(v:[2.0,3.0]) ])
  14. b = M(v:[ V(v:[0.0,0.1]), V(v:[0.2,0.3]) ])
  15. echo M(v: [V(v: [b.v[0].v[0] + a.v[0].v[0], b.v[0].v[1] + a.v[0].v[1]]),
  16. V(v: [b.v[1].v[0] + a.v[1].v[0], b.v[1].v[1] + a.v[1].v[1]])])
  17. b = M(v: [V(v: [b.v[0].v[0] + a.v[0].v[0], b.v[0].v[1] + a.v[0].v[1]]),
  18. V(v: [b.v[1].v[0] + a.v[1].v[0], b.v[1].v[1] + a.v[1].v[1]])])
  19. echo b