RosettaCodeData/Task/Generator-Exponential/SenseTalk/generator-exponential-3.sensetalk
2023-07-01 13:44:08 -04:00

33 lines
682 B
Text

// Main.script to use the generators
set squares to new ExponentialGenerator with {exponent:2}
set cubes to new ExponentialGenerator with {exponent:3}
put "First 10 Squares:"
repeat 10 times
put squares.nextValue
end repeat
put "-" repeated 30 times
put "First 10 Cubes:"
repeat 10 times
put cubes.nextValue
end repeat
put "-" repeated 30 times
set filteredSquares to new FilteredGenerator with {
source: new ExponentialGenerator with {exponent:2},
filter: new ExponentialGenerator with {exponent:3}
}
repeat 20 times
get filteredSquares.nextValue
end repeat
put "Filtered Squares 21 to 30:"
repeat with n=21 to 30
put n & ":" && filteredSquares.nextValue
end repeat