Looping in Python

Ben Wolfson rumjuggler at cryptarchy.org
Mon Dec 17 14:12:46 EST 2001


On Mon, 17 Dec 2001 12:18:16 -0600, Luke <LLoeffler at home.com> wrote:

>If loop were a function, how would you get the code to be executed into 
>the function?

def loop(condition, code):
    def _loop(state):
        if not condition(state):
            _loop(code(state))
        else:
            return state
    return _loop

Or something like that.

-- 
Barnabas T. Rumjuggler
You're going to set me up as a kind of slovenly attached pig that
Jack Kornfeld can slice down in his violent zen compassion?
 -- Larry Block



More information about the Python-list mailing list