Hey,
Finally managed to make an account. Turned out it was just outlook that had a problem.
Anyway, I wanted to start doing some of the /r/dailyprogrammer challenges again and figured I might as well look at some of the last easy ones to get back into it. More specifically for this question, this one: https://www.reddit.com/r/dailyprogrammer/comments/3wdm0w/20151209_challenge_244_easyer_array_language_part/
Just applying generic functions is straight forward enough although slightly annoying to write. I came up with
import future
proc fork[A, B, C, D, E](a: (A, B)->C, b: (C, D)->E, c: (B, A)->D): (A, B)->E =
return proc(x: A, y:B): C = b(a(x, y), c(y, x))
Apparently you can't use generics in nested procs. But how would you keep this function generic while making it work with any number of odd parameters?
It compiles for me, but the correct return type is proc(x: A, y:B): E instead of proc(x: A, y:B): C.
In any case, have a look at the Syntax Cheatsheet linked below to format your code! :-)
Huh, there is a .. code-block:: nimrod before the code block. Guess I forgot the indentation.Errors seem to only be thrown when you actually try to use the proc. Still haven't figured out how to make it work with varying amounts of parameters.
Also, is there a reason that varargs[openarray[int]] and the like don't work?