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

21 lines
739 B
Text

// FilteredGenerator.script
// Takes a source generator, and a filter generator, which must both produce increasing values
// Produces values from the source generator that don't match values from the filter generator
to initialize
set my nextFilteredValue to the nextValue of my filter
end initialize
to handle nextValue
put the nextValue of my source into value -- get a candidate value
-- advance the filter as needed if it is behind
repeat while my nextFilteredValue is less than or equal to value
-- advance value if it's equal to the next filtered value
if my nextFilteredValue = value then set value to my source's nextValue
set my nextFilteredValue to my filter's nextValue
end repeat
return value
end nextValue