Jump to content

Generator/Exponential: Difference between revisions

m
Line 1,751:
 
=={{header|Lingo}}==
Lingo neither supports coroutines nor first-class functions, and also misses syntactic sugar for implementing real generators. But in the context of traditional for-loops, a peculiarity of Lingo can be used to implement generator-like behavior: in Lingo, the halting condition (b) in a "repeat with i = a to b" loop is not pre-cached, but evaluated in each single step. This behavior can be used - in combination with simple pseudo-generator objects that store states internally and manipulate data passed by reference - to implement generator like behavior in loops, and solve the given task.
 
<lang Lingo>squares = script("generator.power").new(2)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.