Hello all,
First, I have a general System RPL question, does anyone know of a
>TCOMP replacement that is faster? By faster I mean for loops with
long lists, etc.
Second, is it possible with assembly to append a list "in-place" without
exploding and rebuilding a list?
Third, I will illustrate some basic situations that illustrate the
>TCOMP slow-down. Take the following System RPL program:
::
NULL{}
BINT101
ONE_DO
INDEX@
>TCOMP
LOOP
;
Very straight forward, start with a empty list, and add the loop index
to the list during each iteration, ending with a list of BINTS from 1 to
100. I tested with longer loops also, below are some timing numbers for
100, 200, 300, 400, 500, and 1000.
100 = 0.525s
200 = 2.057s
300 = 4.886s
400 = 10.938s
500 = 19.525s
1000 = 252.284s
It takes ~37 times longer to build a list 500 than a list of 100, and
~480 times longer for a list of 1000. The reasons are easy to explain
when considering how >TCOMP works, which explodes the list, adds the new
item, and then rebuilds the list. Of course the more objects are in the
list, the more memory is required, and the whole thing becomes much more
involved when there are many items in the list.
Now, to just build a list with a loop, not using >TCOMP is much faster,
as can be demonstrated with the following System RPL program:
::
BINT101
ONE_DO
INDEX@
LOOP
BINT100
{}N
;
This time the program simply returns the index of the loop during each
iteration, and at the end the list is built.
100 = 0.026s
200 = 0.060s
300 = 0.100s
400 = 0.139s
500 = 0.178s
1000 = 0.372s
This time building a list of 500 only takes ~6.8 times longer than a
list of 100, and only ~14.3 times longer to build a list of 1000, a much
more linear correlation.
Sometimes it becomes far too complicated, for example when working with
multiple lists and multiple loops, to perform all the actions involved
using only the stack. It is much easier to have three lists on the
stack and manipulating the contents as required than to have hundreds of
objects from three different lists on the stack and figuring out which
level of the stack you want to get or put something. So, hopefully with
a bit of explanation my two questions make slightly more sense?
First, does anyone know of a >TCOMP replacement that is faster? By
faster I mean for loops with long lists, etc.
Second, is it possible with assembly to append a list "in-place" without
exploding and rebuilding a list?
I searched
hpcalc.org, did a Google search, and have not found anything
on this topic, although it is possible I didn't ask the right questions
for the search I suppose. Any input is appreciated.
Jacob Wall