I am new to the HP50G UserRPL and need advice.
On PCs, I am used to use lists as container for variable structure of
data with nested lists.
aka
{{1 2 3 {4 5}} {4 5 6 {7 8}} {9}} 'mylist' STO
Do I have to write my own GET and PUT functions to access the values or
is it supported in some way?
aka
list {2 4 1} GET -> 7
Thanks
Patrice
the AUR which contains all USER-RPL-Commands is available at
http://www.hpcalc.org/details.php?id=7141.
You can use GET, GETI, PUT, PUTI with lists or arrays.
Be warned that list access is pretty slow because the list has no size
field and thus all access has to be done by slow searching through the
Composite Object.
However, there is a trick to speed up access of Composite Objects by
wrapping them into a Code Object which can be done at compile time but
this "costs" 10 Nibbles for each list and of course this can not be
done in USER-RPL.
Depending on your needs you might want to choose another "container"
for your variables. If you are only using real numbers an array maybe
a better choice.
HTH,
Andreas
http://www.software49g.gmxhome.de
http://www.youtube.com/watch?v=Pj72miclisM
Not even with DevLib functions like COMP-> ->LST
???
> {{1 2 3 {4 5}} {4 5 6 {7 8}} {9}} 'mylist' STO
>
> Do I have to write my own GET and PUT functions to access the values or
> is it supported in some way?
> aka
> list {2 4 1} GET -> 7
list { 2 4 1 } 1 << GET >> DOLIST
-Joe-
Thanks for answers.
I wrote 2 quick and dirty functions to suit my needs.
Patrice
Me again :) still sharpening my skills in UserRPL
I reached the point "Make it right".
Now heading to the point "Make it fast".
Does anybody know about a table measuring speed of commands, telling
what is fast and how fast is fast, what is slow and how slow is slow.
For exemple, I have been told that named vars are slower than stack
operations but I don't know repective speeds.
Thanks in advance
Patrice
One way of finding out relative speeds is by using the TEVAL command.
It effectively mimics the EVAL command but appends the elapsed time for
evaluation to the stack.
Put a program which you wish to test on the stack, or its name if saved
in that directory or above, following any necessary inputs for that
program, then execute TEVAL.
> what is fast and what is slow
Data storing:
Fastest: Stack
Fast: Temporary (local) variables
Slow: User (global, permanent) variables
(particularly when variables change size or are created/deleted)
Calculation:
Fast: Real, Complex
Slow: Integer
Interfaces:
Fast: menu based
Slow: form based
Writing programs:
Some things that are slower to execute
may nonetheless make programming easier, faster,
and even safer (e.g. UserRPL itself).
> how slow is slow
In metric or English units?
[r->] [OFF]
> For exemple, I have been told that named vars are slower than
stack
> operations but I don't know repective speeds.
Generally stack access is the fastest way as this is only a stack of
pointer where each pointer is 5 nibbles wide and generally stack
manipulating commands are PCOs (but some are secondaries - use Nosy to
find out what a kind a command is)
However, if there is a lot of stack movements than NULLAMS are faster,
loading the pointer to a NULLLAM in the range of 1 - 27 is very fast
(ca. 0,05ms according to EMU48) because this done trough one single
command, from LAM 28 it gets a little slower (because the #BINT is
needed).
Named LAMs are at least ten times slower as they are searched in
memory wheras NULLLAMS are calculated.
> PCOs, secondaries, NULLLAMS, BINT, ...
Interesting answers to a UserRPL question.
But there must be lots of SysRPL people reading anyway :)
[r->] [OFF]
I guess your answer is for SysRPL.
Patrice