Talk:List comprehension

message: "This is the near equivalent to the above expression", where the above had "n*n":
  S = [2*x for x in range(101) if x**2 > 3]
Not quite.. "x**2" is very different to "x*x" if x is an integer.  I recently wrote a subnet calculator where multiplying by 2 should be the same as a left shift (endian-ness dependent).  My subnet masks would have been subject to rounding errors!
Feel free to remove this comment once people have finished arguing whether my edit was necessary :-)  —Preceding unsigned comment added by 86.154.39.223 (talk) 22:43, 9 November 2010 (UTC)
thread_title:  Call me a pedant, but.. 

message: "Certain lists are too complex to express by other means." -- An example would be nice.
— Preceding unsigned comment added by 38.119.128.203 (talk) 21:30, 2006 August 31 (UTC)
: It could be easier to give for the previous formulation: "Thus the resulting operation can be complex to express in other means." One example of advanced list comprehension use I've seen is the Haskell solution and generalization here: http://www.frank-buss.de/challenge/index.html --TuukkaH 22:28, 31 August 2006 (UTC)
replies: text: The claim is absurd. -- 98.108.203.136 (talk) 03:20, 30 June 2008 (UTC)
thread_title:  Forms of List Comprehension 

message: Some of the examples use x squared. Others use x*x.
On a language-to-language comparison, this appears to give some languages a syntactic shortness advantage (see ERLANG versus C#). Should we unify the syntax in all languages to use one or the other?
Rbirkby 09:26, 5 June 2007 (UTC)
replies: text: In an encyclopaedia, shouldn't clarity count? --Paddy (talk) 06:21, 12 July 2008 (UTC)
thread_title:  X squared 

message: By "Forms of list comprehension", I wonder if Dreftymac was referring to the fact that The mathematical notation at the head of the article, and the Haskell example both show no upper bound, (except finite resources in Haskells case of course). 
In the examples shown only Haskell and Python give an unbounded version, (I cannot determine if the Visual Prolog example has a fixed upper bound). --Paddy 05:34, 2 September 2007 (UTC)
replies: text: The term "list comprehension" refers to the set builder syntax; bounded/unbounded is an orthogonal concept. You don't need Haskell's lazy evaluation to have list comprehensions. -- 98.108.203.136 (talk) 03:27, 30 June 2008 (UTC)
thread_title:  Bounded/unbounded 

message: Perl 6 has more advanced capabilities, and is in fact very similar to Haskel in some respects.  Someone who is current with it should add an example and discussion of lazy vs. finite list.
— Preceding unsigned comment added by D ugosz (talk • contribs) 18:41, 2007 July 17 (UTC)
:If Perl6 is not yet released , should an example be given? --Paddy 22:26, 18 July 2007 (UTC)
replies: text: I will be deleting the Perl 6 example as Perl 6 is still in active development and an example here is premature/original research --Paddy 06:15, 8 November 2007 (UTC)
thread_title:  (Don't) Need Perl6 Example 

message: The current list example seems inelegant:
S = [ 2*x | x<-[0..], x^2>3 ]
 
If I understand correctly, it'd be this list of numbers:
{ 2,4,6,...}
The even numbers.  It's puzzling why the list notation uses x^2>3 instead of x>1.  Exponents aren't needed to describe even numbers.  --AC 04:53, 7 September 2007 (UTC)
replies: text: A mathematical definition of a set was given. Just because there's some other mathematical definition that yields the same set is irrelevant. -- 98.108.203.136 (talk) 03:33, 30 June 2008 (UTC)
replies: text:  x^2>3 is not really a good example of a filter since it only filters out x = 1, and inelegantly too. Why not use something like x congruent to y mod z? 83.248.95.93 (talk) 08:32, 7 September 2009 (UTC)
replies: text: More people know he notation for square and greater than. It is a major section of the syntax, but the filter expression itself should be chosen to be easily understood and could be something else, but I don't think there is sufficient reason to change, as yet. --Paddy (talk) 17:46, 7 September 2009 (UTC)
thread_title:  "S = [ 2*x | x<-[0..], x^2>3 ]" employs a needless exponent. 

message: The languages which don't have list comprehensions should really be discussing their equivalents of concatMap and filter, rather than map and filter, because in the general case, these are the two things which list comprehensions desugar to.  —Preceding unsigned comment added by 74.124.127.135 (talk) 21:53, 10 October 2007 (UTC)
replies: text: Languages which don't have list comprehension and want to discuss their equivalents of map and filter can do so on the relevant pages Masklinn (talk) 13:42, 18 August 2010 (UTC)
thread_title:  concatMap 

message: I an not a Haskel programmer, but have read several programming languages. I cannot see what this section in the article is about?
I think it should be made more general or deleted if all it is is BNF for Haskels list comprehension syntax. --Paddy (talk) 12:22, 23 June 2008 (UTC)
thread_title:  Translation into list functions<- What is this about? 

message: Haskell seems to not create a list, but to just create something that will iterate over the members of what would be the list, thus allowing the use of unbounded ranges. The introduction seems to say that a list is produced which is not the same thing. Python uses two separate terms here, list comprehensions that create lists and so must be bounded in size, and generator comprehensions which yield successive members of what would be the list when iterated over. I can't think of a rewording of the opening paragraph at the moment, but intermediate lists are not necessarily generated.
If Haskell has no meaningful distinction between a list and the generator that creates list members then that could explain the opening paragraph, but I'm used to lists being of finite size --Paddy (talk) 12:22, 23 June 2008 (UTC)
replies: text: That makes sense, you might want to check on the WP reference desks to see if there is a Haskell person who knows the specific distinction in terminology that they use. Generally, however, since the article should be accessible to a general audience, and this is not exclusively about Haskell, there's no reason why you shouldn't be able to use the intuitive distinction between lists and generators -- a distinction made in many languages, not just Python. dr.ef.tymac (talk) 16:04, 23 June 2008 (UTC)

text: Its a finite generator, of a sequence of members of an infinite list, which can be used where only a computable subset of the members of the list are needed. Haskell and other languages have this ability. --Paddy (talk) 18:34, 30 June 2008 (UTC)
thread_title:  Infinite lists and the introduction 

message: Unless someone can say why not, I am thinking of doing the following edits to remove non LC type syntax in the examples, including all the map+filter based examples as the page is about doing the task using LC's rather than equivalent code for doing the task:
# Remove section "Translation into list functions"
# Haskell: remove all but multiple generator LC example
# Perl: remove map example
# In the section "Parallel list comprehension", leeave only the first paragraph up to, but not including the first example.
--Paddy (talk) 15:13, 24 June 2008 (UTC)
replies: text: More importantly, I think we need a better LC explanation here. It seems that the difference between LC and map+filter is not that obvious. Instead of removing examples (that technically might not be LC, but have pretty similar syntax), I suggest moving them to a new 'equivalent syntax in other languages' section (or something like that) and explaining why the alternative syntax is not LC. Ghettoblaster (talk) 16:56, 24 June 2008 (UTC)
replies: text:  Hi Ghettoblaster, I think the distinction between LC and map+filter has now been made, and highlighting the true LC examples should also make it clear. I am against leaving a section for map+filter examples as those should be on a different page. I am however thinking of expanding on LC syntax. --Paddy (talk) 09:52, 30 June 2008 (UTC)

text: FYI, before reading this, I removed that horrible Haskell-specific and esoteric "Translation into list functions" section. I also fixed the two bugs in the perl example, FWIW. -- 98.108.203.136 (talk) 03:56, 30 June 2008 (UTC)
thread_title:  Removal of non-LC examples 

message: Could the Erlang example be changed to follow the Haskel example in the overview section, then all language examples will do similar things. and be related to the set builder notation expression. --Paddy (talk) 16:23, 22 August 2008 (UTC)
thread_title:  Main Example is in Overview 

message: Why is PostScript referenced in the references section? I don't see it mentioned in the text. Does PostScript have some feature relevant to list comprehensions?  —Preceding unsigned comment added by Ezrakilty (talk • contribs) 12:52, 9 February 2009 (UTC)
thread_title:  PostScript Reference 

message: If Linq does follow set builder syntax, then it would be good if their were Linq examples added to the C# section that implemented the standard examples; then the current Linq info could be removed from the 'Similar constructs' section. --Paddy (talk) 09:46, 26 September 2009 (UTC)
thread_title:  Linq example needed 

message: The first thing that comes to my mind when thinking of th este notation in mathematics is SQL and even more so SPARQL. Am I missing something subtle but deciding or should these both prominently mentioned here?
Hixxxxx (talk) 11:10, 16 March 2011 (UTC)
replies: text: SQL statements are indeed examples of list comprehensions. I see that SQL is mentioned briefly. I think it would be reasonable to give a longer example as is done with the fuller programming languages. I can't speak to SPARQL but perhaps it falls in that category too.  — Preceding unsigned comment added by Ezrakilty (talk • contribs) 13:19, 16 March 2011 (UTC)
thread_title:  SQL, SPARQL,...? 

message: I am waiting for someone to say that Smalltalk-80 select: is a filter and that the collect: message is not an LC.  What else could explain this very biased "history" of LC in programming languages?
Is this about a name for a formal function/mapping/transform or a practice as implemented in the programming languages of an applied science?  If you have doubts, see the minimalist changes to Smalltalk in Seaside that take blocks to continuations and then quote "Smalltalk does not have continuations."  But in practice Smalltalk is a programming environment, not a language definition.
For a useful comparison, look at the impact of genome studies on the previous hierarchies in botany where one standpoint if forced to give way to another (and, yes, I recognize the irony.)
I soon expect to seen an article in which Traits are "shown" in the History section to have come from Scala.
G. Robert Shiplett 17:23, 8 June 2011 (UTC)
thread_title:  Smalltalk and programming bias 

message: Correct me if I'm wrong, I don't have Mathematica and knows very little about the language, but from cursory examination of the code, the Mathematica version seems to be doing something different than the rest of the examples. The examples are supposed to produce the equivalent of s = [ 2*x | x <- [0..100], x^2 > 3 ] but it seems the Mathematica version are doing something like s = [ x | x <- [0..100], x^2 > 3 ]. In other words, I don't see the multiplication by 2 anywhere in the Mathematica version.  — Preceding unsigned comment added by 110.175.240.90 (talk) 15:04, 30 January 2012 (UTC)
replies: text: +1. Removed. _R_ (talk) 16:23, 29 March 2012 (UTC)
thread_title:  Is the Mathematica version correct? 

message: I am thinking of removing the section on "Parallel list comprehension" tomorrow as this is a property of zip() pairing the items in two lists more than adding much to list comprehensions. --Paddy (talk) 05:53, 16 June 2012 (UTC)
thread_title: Remove "Parallel list comprehension" as it is a property of zip?

message: If I understand correctly, it must be some feature built into the language itself, with it's own syntactical form, and not just a function doing the same, even if that function is very compact and elegant. Fx Python list comprehension and the Python map function. If think there should be a small subsection describing how the definition (normally? / always?) only applies to language constructs, not to a function, and then two examples of achieving the same (fx Python list comprehension and map-function), stating that the former is indeed list comprehension, while the latter by definition is not. MadsSkjern (talk) 07:07, 24 May 2015 (UTC)
thread_title:  Example of how it must be syntactical / language construct 

message: Hello fellow Wikipedians,
I have just modified 3 external links on List comprehension. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
*Added archive https://web.archive.org/web/20111008001258/http://w3schools.com/xquery/xquery_flwor.asp to http://www.w3schools.com/XQuery/xquery_flwor.asp
*Added archive https://web.archive.org/web/20051129140339/http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html to http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html
*Added archive https://web.archive.org/web/20051018040438/http://page.axiom-developer.org/zope/mathaction/Streams to http://page.axiom-developer.org/zope/mathaction/Streams
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
Cheers.—InternetArchiveBot (Report bug) 04:20, 24 December 2017 (UTC)
thread_title:  External links modified 

message: Nearly half of the current article is devoted to tangential notes on how you can get something kind of like list comprehensions in C++.
I don't see the relevance for the core concept. It seems clear to me that this material instead belongs on Comparison_of_programming_languages_(list_comprehension).
Does anyone object to me making that change? -- Synechist (talk) 16:15, 27 February 2022 (UTC)
thread_title:  Let's remove the C++ quasi implementation?