37 lines
No EOL
548 B
Text
37 lines
No EOL
548 B
Text
class Finished {}
|
|
let FINISHED = new Finished {};
|
|
|
|
class Iterator {
|
|
current: f64;
|
|
|
|
fun next(self) -> f64 or Finished {
|
|
if self.current < 10 {
|
|
let result = self.current;
|
|
self.current = self.current + 1;
|
|
return result;
|
|
}
|
|
|
|
FINISHED
|
|
}
|
|
}
|
|
|
|
|
|
fun test() -> f64 {
|
|
let result = 1;
|
|
let i = 0;
|
|
while i < 10 {
|
|
result = result * 2;
|
|
i = i + 1;
|
|
}
|
|
|
|
let sum = 0;
|
|
let it = new Iterator { current: 0 };
|
|
while it.next() is v: f64 {
|
|
sum = sum + v;
|
|
}
|
|
|
|
result + sum
|
|
}
|
|
|
|
// @no-errors
|
|
// @eval: Float(1069.0) |