Hi,
As a fairly new but mostly happy Nim user, I have a question whose answer has so far eluded me, despite some trial and error and some googling. I have a closure iterator that works, as long as the iterator itself doesn't take any arguments. I pass that iterator as an argument to a function. That also works. But I can't figure out how to declare an iterator that accepts one or more arguments and then pass the iterator to a function and get that to work. Google AI hallucinated an example that failed with type errors, which is what I'm getting.
I'm not posting my failed code, since I don't want help in fixing it (that's my job). All I need is an example that works in nim-2.2.4.
Thanks.
proc processNumbers(iter: iterator(a, b: int): int) =
for i in iter(7, 2):
echo i
iterator myCountUp(max, incr: int): int {.closure.} =
var i = 0
while i <= max:
yield i
i += incr
processNumbers(myCountUp)
Interactive: https://play.nim-lang.org/#pasty=tNtjqhEL
Need more info or some examples what you're trying to do if this doesn't help.
Google AI hallucinated an example
Deepseek, in my experience, is best for Nim (still gets a lot of stuff wrong), Claude is OK, everything else is pretty much unusable.