On 1/31/2012 4:41 AM, oliverue wrote:
> I'll compare timings against the SEQ version. I figured SEQ was faster
> for larger vectors (say, 10,000 elements) because it doesn't need the
> interpreter for the loop. (FOR-loops are really slow, for some reason.)
FOR is fast when the limits are "real-valued,"
slower when "integer-valued," particularly for longer integers,
because "integer arithmetic" is performed in memory, digit by digit,
rather than in processor registers. SysRPL versions of FOR,
using "bint" limits (20-bit internal unsigned integers), are particularly fast.
As to SEQ, have anti-shock medication on hand before reading this:
"How SEQ works (or doesn't!), plus S/SX version"
<
http://groups.google.com/group/comp.sys.hp48/msg/627c4479ff9da448>
As to why it pays to generate individual elements and defer \->ARRY
until the end, it has always been known, as well as being taught
by example throughout ROM and in SysRPL texts, that processing "meta objects"
(individual elements followed by a counter) on the stack
is the fastest way to handle large lists,
and numerous SysRPL functions exist to perform such actions
as SWAP, ROT, etc. among meta-objects themselves on the stack,
in an already optimized manner.
[r->] [OFF]