Factbites
 Where results make sense
About us   |   Why use us?   |   Reviews   |   PR   |   Contact us  

Topic: List comprehension


Related Topics

  
  5.2.4 List displays
Its contents are specified by providing either a list of expressions or a list comprehension.
When a comma-separated list of expressions is supplied, its elements are evaluated from left to right and placed into the list object in that order.
When a list comprehension is supplied, it consists of a single expression followed by at least one
docs.python.org /ref/lists.html   (165 words)

  
  List comprehension - Wikipedia, the free encyclopedia
List comprehension is a programming language construct for list processing, analogous to the set-builder notation (set comprehension), that is, the mathematical notation such as the following:
The earliest reference to the list comprehension notation is in Rod Burstall and John Darlington's description of their programming language, NPL from 1977, but already SETL had a similar construct.
Comprehensions were proposed as a query notation for databases [1] and were implemented in the Kleisli database query language [2].
en.wikipedia.org /wiki/List_comprehension   (857 words)

  
 List Comprehension   (Site not responding. Last check: 2007-10-23)
List comprehensions are a feature of many modern FunctionalProgrammingLanguages.
A list comprehension is SyntacticSugar for a combination of applications of the functions concat, map and filter.
Expresses a new list as a (potentially complex) function of the old list.
c2.com /cgi/wiki?ListComprehension   (387 words)

  
 Python: List Comprehensions   (Site not responding. Last check: 2007-10-23)
The interesting thing is that we first build a list of non-prime numbers, using a single list comprehension, then use another list comprehension to get the "inverse" of the list, which are prime numbers.
When you can use both, then it is often preferable to use a list comprehension, because this is more efficient and easier to read, most of the time.
You cannot use list comprehensions when the construction rule is too complicated to be expressed with "for" and "if" statements, or if the construction rule can change dynamically at runtime.
www.secnetix.de /~olli/Python/list_comprehensions.hawk   (462 words)

  
 5. Data Structures
The list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (``last-in, first-out'').
Sequence unpacking requires the list of variables on the left to have the same number of elements as the length of the sequence.
Placing a comma-separated list of key:value pairs within the braces adds initial key:value pairs to the dictionary; this is also the way dictionaries are written on output.
docs.python.org /tut/node7.html   (2400 words)

  
 5. Data Structures
The list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (``last-in, first-out'').
Sequence unpacking requires the list of variables on the left to have the same number of elements as the length of the sequence.
Placing a comma-separated list of key:value pairs within the braces adds initial key:value pairs to the dictionary; this is also the way dictionaries are written on output.
www.python.org /doc/current/tut/node7.html   (2396 words)

  
 PEP 202 -- List Comprehensions
This PEP describes a proposed syntactical extension to Python, list comprehensions.
List comprehensions provide a more concise way to create lists in situations where map() and filter() and/or nested loops would currently be used.
List comprehensions become part of the Python language with release 2.0, documented in [1].
www.python.org /dev/peps/pep-0202   (116 words)

  
 [No title]
In any case, list comprehension is a way of doing much of what Python's functional builtins do, but in a much more compact way that is simultaneously easier to read and understand.
This is often useful if you do not want a list comprehension that uses a complete permutation of lists, but merely one that utilized corresponding elements of multiple lists.
As with list comprehensions, no fundamentally new capability is added, but the expression of some common chores is more concise and more clear.
gnosis.cx /publish/programming/charming_python_11.txt   (2103 words)

  
 List comprehensions
Python list comprehensions are a bit more powerful than what I listed here.
List comprehensions are nice because they provide a compact way to represent a common pattern in Python.
Variables in a list comprehension can be used inside of expressions of the list comprehension, so the inner element expression of this list comprehension uses the
www.dalkescientific.com /writings/NBN/list_comps.html   (1098 words)

  
 User talk:TuukkaH - Wikipedia, the free encyclopedia   (Site not responding. Last check: 2007-10-23)
I redirected generator expression to list comprehension as it's notable and in context there.
The article earlier stated that set comprehension was only the notation that S was that particular set (where it isn't, it's only a particular case); I've just made it clear that this is only a particular case.
If we want to discuss the relation between list comprehension and set-builder notation more, a section on their problems might be in place.
en.wikipedia.org /wiki/User_talk:TuukkaH   (1980 words)

  
 5.2.4 List displays
Its contents are specified by providing either a list of expressions or a list comprehension.
When a comma-separated list of expressions is supplied, its elements are evaluated from left to right and placed into the list object in that order.
When a list comprehension is supplied, it consists of a single expression followed by at least one
www.python.org /doc/ref/lists.html   (165 words)

  
 [No title]
We find list comprehensions slighly easier to manipulate than the more traditional algebraic operators, but it is not hard to translate comprehensions into these operators (or vice versa).
Lists and tuples use related forms for values and types, we hope this is helpful rather than confusing.
If it is empty, the match fails (returns an empty list); otherwise, there is one successful match, the value is the node at the head of the list and the remaining list of nodes is the tail of the list.
homepages.inf.ed.ac.uk /wadler/papers/xquery-algebra/xquery-algebra.html   (4583 words)

  
 VisualProlog 7 Tutorials: Lists and Recursion   (Site not responding. Last check: 2007-10-23)
Lists correspond roughly to arrays in other languages, but, unlike an array, a list does not require you to declare how big it will be before you use it.
A list is a recursive compound object that consists of a head and a tail.
List processing consists of recursively removing the head of the list (and usually doing something with it) until the list is an empty list.
www.visual-prolog.com /vip6/Tutorial/tut16/Lists.htm   (4437 words)

  
 An Introduction to Python Lists ::: www.effbot.org
Lists implement the standard sequence interface; len(L) returns the number of items in the list, L[i] returns the item at index i (the first item has index 0), and L[i:j] returns a new list, containing the objects between i and j.
The size of a list in memory depends on the number of objects in the list, not the size of the objects.
The time needed to append an item to the list is "amortized constant"; whenever the list needs to allocate more memory, it allocates room for a few items more than it actually needs.
effbot.org /zone/python-list.htm   (2118 words)

  
 XSIBlog » Blog Archive » Looping with Python in XSI   (Site not responding. Last check: 2007-10-23)
In fact, the execution time of the list comprehensions and the map() function is somewhat inconsistent, and sometimes the map() function is quicker.
List comprehension, when involving testing types and iterating over sequences of objects, is slower than the sequence for loop.
Possibly the list comprehension right after the map/lambda that flattens the values may involve a performance hit that nullifies the use of the map/lambda combination.
www.xsi-blog.com /?p=31   (6523 words)

  
 Charming Python: Getting version 2.0   (Site not responding. Last check: 2007-10-23)
In any case, list comprehension is a way of doing much of what Python's functional built-ins do, but in a much more compact way that is simultaneously easier to read and understand.
>>> # Functional-style spaghetti for list comprehension >>> filter(lambda (x,y): x*y > 25,.....
As with list comprehensions, no fundamentally new capability is added, but the expression of some common chores is clearer and more concise.
www-128.ibm.com /developerworks/opensource/library/l-py20.html   (2227 words)

  
 Byte of Python:More Python - Text
List comprehensions are used to derive a new list from an existing sequence.
For example, you have a list of numbers and you want to get a corresponding list of numbers multiplied by 2 but only when the number is greater than 2.
You could create an empty list, and then calculate these numbers and append to the list one-by-one, or you could take the simpler route and use list comprehensions.
www.swaroopch.info /text/Byte_of_Python:More_Python   (975 words)

  
 qlc   (Site not responding. Last check: 2007-10-23)
As already mentioned queries are stated in the list comprehension syntax as described in the Erlang Reference Manual.
The ordinary list comprehension is normally to be preferred when there is a choice as to which to use.
This is always true for the top-most query list comprehension and also for the list expression of the first generator in a list of qualifiers.
www.erlang.se /doc/doc-5.4/lib/stdlib-1.13/doc/html/qlc.html   (3460 words)

  
 Improving List Comprehension Database Queries - Wadler (ResearchIndex)   (Site not responding. Last check: 2007-10-23)
In this paper we describe the improvement of queries expressed as list comprehensions in a lazy functional language.
2 Syntax of Object Comprehensions The syntax of object comprehensions is...
Comprehensions, a Query Notation for DBPLs - Trinder (1990)
sherry.ifi.unizh.ch /wadler89improving.html   (643 words)

  
 The Haskell 98 Report: Expressions
Standard operations on lists are given in the Prelude (see Section 6.1.3, and Chapter 8 notably Section 8.1).
Such a list comprehension returns the list of elements produced by evaluating e in the successive environments created by the nested, depth-first evaluation of the generators in the qualifier list.
List comprehensions satisfy these identities, which may be used as a translation into the kernel:
haskell.org /onlinereport/exps.html   (3610 words)

  
 List Comprehensions   (Site not responding. Last check: 2007-10-23)
List comprehensions provide a very easy means to manipulate lists of elements.
In this example, we have produced a new list, where each element is obtained by squaring an element in the input list.
List comprehensions can also be used to filter lists.
nltk.sourceforge.net /tutorial/advpython/section-list_comprehensions.html   (257 words)

  
 List comprehension - Computing Reference - eLook.org
This returns all pairs of numbers (x,y) where x and y are elements of the list 1, 2,..., 10, y <= x and their sum is less than 10.
A list comprehension is simply "syntactic sugar" for a combination of applications of the functions, concat, map and filter.
The term "list comprehension" appears in the references below.
www.elook.org /computing/list-comprehension.htm   (231 words)

  
 Charming Python: Getting version 2.0
In any case, list comprehension is a way of doing much of what Python's functional built-ins do, but in a much more compact way that is simultaneously easier to read and understand.
>>> # Functional-style spaghetti for list comprehension >>> filter(lambda (x,y): x*y > 25,.....
As with list comprehensions, no fundamentally new capability is added, but the expression of some common chores is clearer and more concise.
www-106.ibm.com /developerworks/linux/library/l-py20.html   (2227 words)

  
 Understanding Monads Via Python List Comprehensions
List comprehensions are a great Python feature that have been borrowed from Haskell/ML, and ultimately from set theory.
The list comprehension knows all about creating an empty initial list and appending values etc, so we don't have to do that each time.
While list comprehension are specific to creating lists, 'do' notation has no knowledge of lists at all.
lukeplant.me.uk /blog.php?id=1107301643   (1927 words)

  
 Are List Comprehensions the Wrong Way Round?
First, you’ll need to list your Picassos – which means someone visiting each room in the gallery, looking in all the artworks in that room and noting down the ones by Picasso.
Python 2.0 introduced list comprehensions – a neat way of building lists from lists (or indeed any other iterable).
The reason Python's list comprehensions are that way around is because they originate from list comprehensions in functional languages, which in turn come from the mathematical set-builder notation.
blog.wordaligned.org /articles/2006/08/13/are-list-comprehensions-the-wrong-way-round   (439 words)

  
 Lazily evaluated list generation functions - perl6:
Lists, whether generated lazily or not, are assumed to be stable.
The values of previous elements are not passed to the list generation function with the ':' syntax.
However, if lazy list elements are calculated efficiently on demand, the need for a programmer to access the list generation parameters at all should be limited.
dev.perl.org /rfc/81.html   (1523 words)

  
 [No title]
When comparing comprehension and fluency measures, a significant difference was not found between the participants’ performance of word list reading (at the independent and instructional level) and reading comprehension at the independent levels.
The purpose of this study was to examine the relationship between three informal reading measures (i.e., word list reading, oral answering of comprehension questions, and oral reading rate) used to assess the reading abilities of thirty-six 8th grade students considered to be at-risk for academic failure.
Word list reading at the instructional level was the only measure for which the participant groups mean performance was at or above their grade.
www.speechpathology.com /articles/pf_article_detail.asp?article_id=216   (3097 words)

  
 Haskell Tutorial
In the second list, the difference between the first two elements is used to compute the remaining elements in the series.
List comprehensions give a concise syntax for a rather general class of iterations over lists.
One interesting application of infinite lists is to act as lookup tables for caching the values of a function.
moonbase.wwc.edu /~cs_dept/KU/PR/Haskell.html   (3443 words)

  
 SRFI 42: Eager Comprehensions
An eager comprehension is a convenient notation for one or more nested or parallel loops generating a sequence of values, and accumulating this sequence into a result.
A comprehensions is a hygienic referentially transparent macro in the sense of [R5RS, 4.3.].
The comprehension constructs a new array of the given shape by filling it row-major with the sequence of elements as specified by the qualifiers.
srfi.schemers.org /srfi-42/srfi-42.html   (6493 words)

  
 ASPN : Python Cookbook : SQL-like set operations with list comprehension one-liners.   (Site not responding. Last check: 2007-10-23)
Sometimes it is needed to do set-like operations on database query results, or simple lists, without the burden of implementing a class for sets, or importing a separate module.
List comprehensions are quick way to do this, here is a collection of them.
Then I took the set operations one by one, most of them turned out to be banal with list comprehensions, but since I took the effort to try them out I included them in the recipe.
aspn.activestate.com /ASPN/Cookbook/Python/Recipe/159974   (359 words)

  
 another list comprehension   (Site not responding. Last check: 2007-10-23)
Forming a list out of another list can be achieved with one line of code.
tclsh> # squaring all elements in a list tclsh> proc sqr {x} {expr {$x*$x}} tclsh> ::struct::list map {1 2 3 4 5} sqr 1 4 9 16 25 tclsh> # Retrieving the second column from a matrix tclsh> # given as list of lists.
NEM: List comprehensions can be generalised to support not just lists, but any structure supporting two operations: one which wraps a value into an instance of the structure, and another which takes a function and applies it to a member of the structure, returning a new instance of the structure.
wiki.tcl.tk /17471   (1202 words)

Try your search on: Qwika (all wikis)

Factbites
  About us   |   Why use us?   |   Reviews   |   Press   |   Contact us  
Copyright © 2005-2007 www.factbites.com Usage implies agreement with terms.