List comprehensions: Difference between revisions
m
Fixed lang tags (using MediaWiki::API).
No edit summary |
Underscore (talk | contribs) m (Fixed lang tags (using MediaWiki::API).) |
||
Line 22:
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}}
<lang
OP +:= = (REF FLEX[]XYZ lhs, XYZ rhs)FLEX[]XYZ: (
Line 43:
=={{header|C++}}==
<lang
#include <cmath>
#include <iostream>
Line 76 ⟶ 75:
}
This produces the following output:
3 4 5 5 12 13 6 8 10 8 15 17 9 12 15 12 16 20</lang>
=={{header|Clojure}}==
<lang
=={{header|Common Lisp}}==
Line 112 ⟶ 110:
=={{header|E}}==
=={{header|Erlang}}==
<lang
=={{header|Haskell}}==
Line 140 ⟶ 138:
=={{header|J}}==
The idiom here has two major elements:
Line 179 ⟶ 177:
=={{header|Mathematica}}==
=={{header|OCaml}}==
Line 218 ⟶ 216:
List comprehension:
A Python generator comprehension (note the outer round brackets), returns an iterator over the same result rather than an explicit list:
=={{header|Ruby}}==
Line 285 ⟶ 283:
TI-89 BASIC does not have a true list comprehension, but it has the seq() operator which can be used for some similar purposes.
produces {1, 4, 9, 16}. When the input is simply a numeric range, an input list is not needed; this produces the same result:
|