Guest User

Untitled

a guest
Jul 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. proc `^`*(f: proc(x: untyped): untyped, power: int): proc(x: untyped): untyped =
  2. ## "Exponentiation" of a function
  3. ## (f^n)(x) := f(f(f( ... n times ... f(f(f(x))) ... )))
  4. return proc(x: untyped): untyped =
  5. result = x
  6. for _ in 1 .. power:
  7. result = f(result)
Add Comment
Please, Sign In to add comment