Content deleted Content added
→Python primes generator contributed by banned user: Python expression explanation |
|||
Line 110:
</pre>
[[User:CheyenneWills|CheyenneWills]] 05:20, 28 November 2006 (UTC)
The Generator expression example for Icon can be simplified and does not require a co-expression.
<source lang=pascal>
local j
every j := (|seq(0) \ 20) ^2 do # Produced the first 20 squares
write(j)
</source>
If the idea is to demonstrate really what Icon can do in terms of using generators outside a loop construct, the following may be a better example
<source lang=pascal>
# find the first matching element
a := [1,2,3,4]
b := [5,6,2,7]
c := ( !a = !b ) | &null # assign first matching element, or set to &null
</source>
[[User:CheyenneWills|CheyenneWills]] ([[User talk:CheyenneWills|talk]]) 20:01, 16 June 2010 (UTC)
== Generator in Ruby ==
|