type Polynomial*[A] = object
coefficients*: seq[A]
proc poly*[A](a: varargs[A]): Polynomial[A] =
Polynomial[A](coefficients: a)
but this fails with Error: type mismatch: got (varargs[int literal(2)]) but expected 'seq[int literal(2)]'.
Fair enough, according to the documentation the varargs are an array, so I should convert that to seq. Since any iterator implements toSeq, my next attempt would be
proc poly*[A](a: varargs[A]): Polynomial[A] =
Polynomial[A](coefficients: a.items.toSeq)
This fails with the message
Error: expression '(system.items|system.items|system.items|system.items|system.items|system.items|system.items|...)' cannot be called.
What would be right way to convert an array to a seq? Of course, I can manually iterate, doing something like
proc toSeq[A](xs: openarray[A]): seq[A] =
result = @[]
for i in xs:
result.add(i)
but I feel I am missing something much more basic