A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-July/006115.html below:

[Python-Dev] re: list comprehension / pop quiz

[Python-Dev] re: list comprehension / pop quizJeremy Hylton jeremy@beopen.com
Tue, 11 Jul 2000 16:20:36 -0400 (EDT)
>>>>> "GvR" == Guido van Rossum <guido@beopen.com> writes:

  GvR> I'm afraid the answer will be the same, if these are again
  GvR> numerical analysts -- these people live by nested DO loops. :-(

If we end up calling this new feature list comprehensions, we might
create the expectation that they behave like list comprehensions in
other languages.

Haskell is one language with comprehensions and they behave the way
that the numerical analysts expect them to behave.  Maybe we should
chalk it up to numerical analysts and funtional programmers being
weird, but they may be on to something.

Here's a short excerpt from the Gentle Introduction to Haskell:
http://www.haskell.org/tutorial/goodies.html (Sec. 2.4.1)

>[ f x | x <- xs ]
>This expression can intuitively be read as "the list of all f x such
>that x is drawn from xs." The similarity to set notation is not a
>coincidence. The phrase x <- xs is called a generator, of which more
>than one is allowed, as in:
>
>[ (x,y) | x <- xs, y <- ys ]
>
>This list comprehension forms the cartesian product of the two lists
>xs and ys. The elements are selected as if the generators were
>"nested" from left to right (with the rightmost generator varying
>fastest); thus, if xs is [1,2] and ys is [3,4], the result is
>[(1,3),(1,4),(2,3),(2,4)].

Jeremy



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