Re: Tail recursion to while iteration in 2 easy steps

Discussion in 'Python' started by Mark Janssen, Oct 2, 2013.

  1. Mark Janssen

    Mark Janssen Guest

    >> Part of the reason that Python does not do tail call optimization is
    >> that turning tail recursion into while iteration is almost trivial, once
    >> you know the secret of the two easy steps. Here it is.

    >
    > That should be a reason it _does_ do it - saying people should rewrite
    > their functions with loops means declaring that Python is not really a
    > multi-paradigm programming language but rather rejects functional
    > programming styles in favor of imperative ones.


    Yes, but that's fine. A PL language that includes every programming
    paradigm would be a total mess, if even possible. Python has
    functional programming where it does not conflict with its overall
    design. The only place I find that this is not the case is with
    lambda, but that is now adequately fixed with the addition of the
    ternary operator.

    --
    MarkJ
    Tacoma, Washington
    Mark Janssen, Oct 2, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Terry Michaels

    Tail Call Optimization (Tail Recursion)

    Terry Michaels, Apr 18, 2011, in forum: Ruby
    Replies:
    16
    Views:
    303
    Robert Klemme
    Apr 20, 2011
  2. Terry Reedy
    Replies:
    66
    Views:
    361
    Charles Hixson
    Oct 9, 2013
  3. Replies:
    3
    Views:
    129
    Steven D'Aprano
    Oct 2, 2013
  4. Terry Reedy
    Replies:
    1
    Views:
    124
    88888 Dihedral
    Oct 4, 2013
  5. Replies:
    1
    Views:
    91
    Steven D'Aprano
    Oct 4, 2013
Loading...

Share This Page