A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/092064.html below:

do...until wisdom found...

do...until wisdom found... do...until wisdom found...Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Wed Apr 18 16:47:45 EDT 2001
Tue, 17 Apr 2001 09:28:15 -0700, Bob Cannard <bob_cannard at mentor.com> pisze:

> As a result, most non-for loops degenerate into
> 
>         while 1:
>             set up for this cycle
>             if c: break
>             whatever needs to be done

Some languages express loops with no looping keywords at all.
Loops of this style are written thus:

    def loop():
        set up for this cycle
        if not c:
            whatever needs to be done
            loop()
    loop()

(and run in constant memory despite the recursion). It's simpler in
the idea than those while/do/until/break/repeat stories because it
doesn't need more additional concepts than those which have to be
present anyway.

When a state is to be maintained through the loop, it's usually passed
as arguments to the recursive function.

Since it's sometimes too verbose, there are functions which wrap common
patterns of loops. This is where map, filter and reduce came from, and
list comprehensions.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4