Generator (computer programming): Difference between revisions

Content deleted Content added
m top: clean up; http->https (see this RfC) using AWB
Added section for R
Line 544:
console.log(gen.next().value); // 5
console.log(gen.next().value); // 8
</source>
 
===R===
 
The iterators package can be used for this purpose <ref>{{cite web|url=http://stackoverflow.com/a/16028448/4745348}}</ref>.
 
<source lang="R">
# See http://stackoverflow.com/a/16028448/4745348 and http://cartesianfaith.wordpress.com/2013/01/05/infinite-generators-in-r/
 
library(iterators)
 
# Example ------------------
abc <- iter(c('a','b','c'))
nextElem(abc)
</source>