List comprehensions: Difference between revisions

Content added Content deleted
(Distinct from map & filter too!)
Line 4: Line 4:


Some attributes of a list comprehension are that:
Some attributes of a list comprehension are that:
# They should be distinct from (nested) for loops within the syntax of the language.
# They should be distinct from (nested) for loops and the use of map & filter functions within the syntax of the language.
# They should return either a list or an iterator (something that returns successive members of a collection, in order).
# They should return either a list or an iterator (something that returns successive members of a collection, in order).
# The syntax has parts corresponding to that of [[wp:Set-builder_notation|set-builder notation]].
# The syntax has parts corresponding to that of [[wp:Set-builder_notation|set-builder notation]].