Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
// ExponentialGenerator.script
|
||||
|
||||
to initialize
|
||||
set my base to 0
|
||||
if my exponent is empty then set my exponent to 1 -- default if not given
|
||||
end initialize
|
||||
|
||||
to handle nextValue
|
||||
add 1 to my base
|
||||
return my base to the power of my exponent
|
||||
end nextValue
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// 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
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue