Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc `^`*(f: proc(x: untyped): untyped, power: int): proc(x: untyped): untyped =
- ## "Exponentiation" of a function
- ## (f^n)(x) := f(f(f( ... n times ... f(f(f(x))) ... )))
- return proc(x: untyped): untyped =
- result = x
- for _ in 1 .. power:
- result = f(result)
Add Comment
Please, Sign In to add comment