etymology of "list comprehension"?

Discussion in 'Python' started by mh@pixar.com, Nov 6, 2008.

  1. Guest

    I googled and wiki'ed, but couldn't find a concise clear answer
    as to how python "list comprehensions" got their name.

    Who picked the name? What was the direct inspiration, another
    language? What language was the first to have such a construct?

    I get that it's based on set notation.

    Thanks!
    Mark

    --
    Mark Harrison
    Pixar Animation Studios
    , Nov 6, 2008
    #1
    1. Advertising

  2. Chris Rebert Guest

    On Thu, Nov 6, 2008 at 1:19 PM, <> wrote:
    > I googled and wiki'ed, but couldn't find a concise clear answer
    > as to how python "list comprehensions" got their name.
    >
    > Who picked the name? What was the direct inspiration, another
    > language? What language was the first to have such a construct?


    According to Wikipedia, the SETL programming language was the first
    one to have such a construct. My understanding is that Python took the
    idea from Haskell, where the concept has the same name. The term
    "comprehension" for the concept was first used in the NPL programming
    language (Wikipedia again).

    Cheers,
    Chris
    --
    Follow the path of the Iguana...
    http://rebertia.com

    >
    > I get that it's based on set notation.
    >
    > Thanks!
    > Mark
    >
    > --
    > Mark Harrison
    > Pixar Animation Studios
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
    Chris Rebert, Nov 6, 2008
    #2
    1. Advertising

  3. Guest

    Chris Rebert <> wrote:
    > the term
    > "comprehension" for the concept was first used in the NPL programming
    > language (Wikipedia again).


    Ah, thanks... and does "comprehension" have any special computer
    science meaning?

    --
    Mark Harrison
    Pixar Animation Studios
    , Nov 6, 2008
    #3
  4. Terry Reedy Guest

    wrote:
    > I googled and wiki'ed, but couldn't find a concise clear answer
    > as to how python "list comprehensions" got their name.
    >
    > Who picked the name? What was the direct inspiration, another
    > language? What language was the first to have such a construct?
    >
    > I get that it's based on set notation.


    The etymology of 'com-prehend' is with-grab, where prehend comes from
    the same Latin verb as prehensile (able to grab). A set comprehension
    (which has also been called things like 'set-builder notation') includes
    or grabs the whole set in one expression, instead of listing members
    one-by-one.

    tjr
    Terry Reedy, Nov 7, 2008
    #4
  5. Paul Rubin Guest

    writes:
    > Ah, thanks... and does "comprehension" have any special computer
    > science meaning?


    It is from mathematical set theory. If you write something like

    { p | [some logical expression indicating that p is prime] }

    then that denotes a set (the set of all prime numbers). That every
    such formula names a set is called the axiom of comprehension. The
    above notation is sometimes called set-builder notation.

    Frege's original system of logic (late 19th century), now called
    "naive set theory" had "unrestricted comprehension" which meant
    you could say anything at all where the logical expression went.
    This made the system inconsistent, because of Russell's paradox
    ("c is the class of all classes that are not members of themselves.
    So is c a member of itself?").

    Axiomatic set theory has a restricted axiom of comprehension that
    requires the logical expression to be a first order formula with
    a certain syntax, to avoid such paradoxes.

    Anyway, list comprehensions in programming languages got their
    name because of their resemblance to set-builder notation that
    invoked the axiom of comprehension.
    Paul Rubin, Nov 7, 2008
    #5
  6. James Harris Guest

    On 6 Nov, 22:13, wrote:
    > Chris Rebert <> wrote:
    > > the term
    > > "comprehension" for the concept was first used in the NPL programming
    > > language (Wikipedia again).

    >
    > Ah, thanks... and does "comprehension" have any special computer
    > science meaning?


    Good question. It seems that comprehension in this case relates to
    comprehensiveness - i.e. a note of how complete a set is. From the
    list at

    http://www.onelook.com/?w=comprehension&ls=a

    check out in particular Merriam-Webster meanings 2a and 2b, and
    Wikipedia for comprehension (logic).

    --
    HTH,
    James
    James Harris, Nov 7, 2008
    #6
  7. Terry Reedy Guest

    Paul Rubin wrote:
    > writes:
    >> Ah, thanks... and does "comprehension" have any special computer
    >> science meaning?

    >
    > It is from mathematical set theory. If you write something like
    >
    > { p | [some logical expression indicating that p is prime] }
    >
    > then that denotes a set (the set of all prime numbers). That every
    > such formula names a set is called the axiom of comprehension. The
    > above notation is sometimes called set-builder notation.
    >
    > Frege's original system of logic (late 19th century), now called
    > "naive set theory" had "unrestricted comprehension" which meant
    > you could say anything at all where the logical expression went.
    > This made the system inconsistent, because of Russell's paradox
    > ("c is the class of all classes that are not members of themselves.
    > So is c a member of itself?").
    >
    > Axiomatic set theory has a restricted axiom of comprehension that
    > requires the logical expression to be a first order formula with
    > a certain syntax, to avoid such paradoxes.
    >
    > Anyway, list comprehensions in programming languages got their
    > name because of their resemblance to set-builder notation that
    > invoked the axiom of comprehension.


    Thank you for this info. I suspected something along this line but
    could not quite remember.
    Terry Reedy, Nov 7, 2008
    #7
  8. wrote:
    > Chris Rebert <> wrote:
    >> the term
    >> "comprehension" for the concept was first used in the NPL programming
    >> language (Wikipedia again).

    >
    > Ah, thanks... and does "comprehension" have any special computer
    > science meaning?


    Paul already explained the maths, but I find that the etymology remains
    unclear still. In any case, the Wikipedia article
    Axiom_schema_of_specification says that the following names are used
    for this axiom:
    - axiom schema of specification,
    - axiom schema of separation,
    - subset axiom scheme or
    - axiom schema of restricted comprehension

    I think the "comprehension" definition goes back to this definition from
    logic:

    # In logic, the comprehension of an object is the totality of
    # intensions, that is, attributes, characters, marks, properties, or
    # qualities, that the object possesses, or else the totality of
    # intensions that are pertinent to the context of a given discussion.

    So you get an "intensional" definition of a set: give me all object
    with a certain comprehension - as opposed to "extensional" definition,
    such as "the set of all capitals consists of Paris, London, Berlin,
    Madrid, ..."

    The definition in logic, in turn, matches my understanding of the
    English word "to comprehend": If I know all attributes, marks,
    etc of an object, I understand it fully, i.e. I comprehend it.

    Regards,
    Martin
    Martin v. Löwis, Nov 7, 2008
    #8
    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. Replies:
    3
    Views:
    374
    Ron Natalie
    Mar 4, 2005
  2. Laura Creighton
    Replies:
    0
    Views:
    368
    Laura Creighton
    Sep 13, 2003
  3. Etymology of "struct"

    , Mar 31, 2007, in forum: C Programming
    Replies:
    20
    Views:
    920
    Chris Torek
    Apr 3, 2007
  4. mdh

    Etymology of subscript in C ( OT)

    mdh, Sep 14, 2007, in forum: C Programming
    Replies:
    5
    Views:
    324
    Richard Tobin
    Sep 14, 2007
  5. Vedran Furac(
    Replies:
    4
    Views:
    324
    Marc 'BlackJack' Rintsch
    Dec 19, 2008
Loading...

Share This Page