RosettaCodeData/Task/List-comprehensions/00DESCRIPTION

18 lines
988 B
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
{{Omit From|Modula-3}}
{{omit from|ACL2}}
{{omit from|BBC BASIC}}
2013-04-10 21:29:02 -07:00
A [[wp:List_comprehension|list comprehension]] is a special syntax in some programming languages to describe lists. It is similar to the way mathematicians describe sets, with a ''set comprehension'', hence the name.
2016-12-05 22:15:40 +01:00
Some attributes of a list comprehension are:
# They should be distinct from (nested) for loops and the use of map and filter functions within the syntax of the language.
2013-04-10 21:29:02 -07:00
# 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]].
2016-12-05 22:15:40 +01:00
;Task:
Write a list comprehension that builds the list of all [[Pythagorean triples]] with elements between   '''1'''   and   '''n'''.
If the language has multiple ways for expressing such a construct (for example, direct list comprehensions and generators), write one example for each.
<br><br>