Generator/Exponential: Difference between revisions
Content added Content deleted
Line 1,751: | Line 1,751: | ||
=={{header|Lingo}}== |
=={{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 - to implement generator like behavior in loops, and solve the given task. |
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) |
<lang Lingo>squares = script("generator.power").new(2) |