From ftm
Q: How can I fill a vector from 0 to an incoming number?
A: The ramp or rampinc methods of fmat or fvec are made for this:
($myvec ramp 0 $1)
fills the existing elements to ($1 - 1)
($myvec rampinc 0 $1)
fills to $1. The fmat or fvec must have the correct size already. (Change with rows $1.)
Exercise: Using the expr class:
Having first resized the vector to N+1, where N is incoming number, declare the expression rampexpr in an ftm.object like
[expr '($idx)' | rampexpr]
Then it's:
($myvec fill $rampexpr)
If you have a vector whose size you want to keep fixed, so that you go, say, 0-13 in 10 steps, it's a bit more complex with expr, but only a bit:
To go 0 to N inclusive (like rampinc):
[expr '($idx * ($1 / (($self size) - 1) ) )' | rampexpr2]
To go 0 to N-1:
[expr '($idx * ($1 / ($self size) ) )' | rampexpr3]
($myvec fill $rampexpr2 $1)
Assuming $1 is your incoming value.
(Owen Green, Diemo Schwarz)