On Tue, 18 Dec 2012, Stefano Fachin wrote:
just thinking: it would be nice to have a "goto" control
inside loops. In Monte Carlo sometimes there is the need to
discard one of the replications, jumping to the next.
Hmm, "goto" is generally (although not universally) considered
bad mojo. I suppose we could have "continue", though I
wouldn't rate it a high priority since there's nothing you
could do with "continue" that you can't already do with "if".
For example, suppose you want N results from some procedure
that might not "succeed" every time.
<hansl>
scalar N = 10
matrix results = zeros(N, 1)
scalar i = 1
loop while i <= N
scalar result = randgen1(z, 0, 1)
if result > -0.5
results[i] = result
i++
endif
endloop
print results
</hansl>
Allin Cottrell