News for hackers. Stuff that matters.
Re:Functional Python Programming by _aavaa_ on Friday June 09, 2023 @12:56PM (#36260670)
You can do a similar thing (that's around 2-3x faster) with a trampoline:

  def factorial(n):
      res = fac(n)
      while callable(res):
          res = res()

      return res

  def fac(n, acc=1):
      if n == 1:
          return acc
      else:
          return lambda: fac(n-1, n*acc)

There are no comments on this comment yet.