Function composition: Difference between revisions

m
The Nim types were wrong, such that both f() and g() had to have identical input and return types, while in the update, you could have f() take an int, return a string, while g() takes in a string and returns an int.
m (The Nim types were wrong, such that both f() and g() had to have identical input and return types, while in the update, you could have f() take an int, return a string, while g() takes in a string and returns an int.)
Line 2,139:
<syntaxhighlight lang="nim">import sugar
 
proc compose[A,B,C](f: AB -> BC, g: BA -> CB): A -> C = (x: A) => f(g(x))
 
proc plustwo(x: int): int = x + 2
7

edits