tseq2.nim 290 B

123456789101112
  1. proc `*` *(a, b: seq[int]): seq[int] =
  2. # allocate a new sequence:
  3. newSeq(result, len(a))
  4. # multiply two int sequences:
  5. for i in 0..len(a)-1: result[i] = a[i] * b[i]
  6. when isMainModule:
  7. # test the new ``*`` operator for sequences:
  8. assert(@[1, 2, 3] * @[1, 2, 3] == @[1, 4, 9])