mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
12 lines
292 B
Nim
12 lines
292 B
Nim
proc `*` *(a, b: seq[int]): seq[int] =
|
|
# allocate a new sequence:
|
|
newSeq(result, len(a))
|
|
# multiply two int sequences:
|
|
for i in 0..len(a)-1: result[i] = a[i] * b[i]
|
|
|
|
when isMainModule:
|
|
# test the new ``*`` operator for sequences:
|
|
assert(@[1, 2, 3] * @[1, 2, 3] == @[1, 4, 9])
|
|
|
|
|