Charles Childers


blog | parable | retro | ios apps | fountain pens


Parable: Simple Counted Loops w/Index

Parable's standard set of loop operations provides times for performing simple counted loops. But this doesn't provide an index. which is sometimes useful. We can simulate this though using a list and for-each.

"Construct a list of values from 1 to 10"
[ 1 10 range ] capture-result

"Do something. The index (the stored value in the list)"
"will be passed in on each cycle"
[ #nan cons 'This is cycle {v}' interpolate<cycling> ]
for-each

I may try to wrap this in a slightly more elegant way later, but it's good enough for now.