fork download
  1. # モジュールA
  2. var
  3. x*, y: int
  4.  
  5. proc `*` *(a, b: seq[int]): seq[int] =
  6. # 新しいシーケンスを割り当てる
  7. newSeq(result, len(a))
  8. # 二つのシーケンスを掛け合わせる
  9. for i in 0..len(a)-1: result[i] = a[i] * b[i]
  10.  
  11. when isMainModule:
  12. # 新しく作ったシーケンスのための``*``演算子を試す
  13. assert(@[1, 2, 3] * @[1, 2, 3] == @[1, 4, 9])
  14.  
Success #stdin #stdout 0s 4312KB
stdin
Standard input is empty
stdout
Standard output is empty