Thanks, tin3tin. A good example of how GScript makes this sort of thing easier to write.
Of course, it can also be done in standard Avisynth by using recursive procedures, but most people would find it more natural to write an iterative construction like this directly as a loop.
Note that the GScript call need not be confined to the 'non-standard' parts of the script. For example, each function (or even both together) could be put inside GScript. This way, the GScript parser is invoked only once, rather than on each call to the function.
For example,
Code:
GScript("""
function Gradient( ... ) {
...
}
function GradientNoSpline( ... ) {
...
}
""")