Re: Error: got proc, but expected proc {.closure.}
Thank you guys! You helped a lot!
Re: Error: got proc, but expected proc {.closure.}
You need to provide an anonymous proc. This works: import sugar proc calc(a: int, b: int): (int) -> int = let diff = a - b result = proc (c: int): int = result = c - diff let diff_proc = calc(5, 6) echo diff_proc(7) Run
Re: Error: got proc, but expected proc {.closure.}
The proc you want to return shouldn't have a name. So this line: result = proc differentiate(c: int): int = Run should be result = proc (c: int): int = Run
Re: Error: got proc, but expected proc {.closure.}
the error message could be better, but the problem is that a reguarly created proc (with name) is not a value. There are two solutions: proc calc(a: int, b: int): (int) -> int = let diff = a - b result = proc(c: int): int = result = c - diff Run or proc calc(a: int, b: int): (int) -> int = let diff = a - b proc differentiate(c: int): int = result = c - diff differentiate Run