I'd like to know if there's some trick to calculate the sum of all the
existing values of the stack so I can avoid the use of the plus key
all the time (sometimes I need to calculate the sum of twenty or more
values - integers most of the time - ). Do I need to write a program
to do that? If that were de case, would you mind to write it down for
me?
Really, thank you very much,
Francesc
DEPTH ->LIST
DUP LIST->
1 SWAP
START
+
NEXT
HTH
Raymond
"franfar" <fra...@gmail.com> schrieb im Newsbeitrag
news:86ce8c0e-9ada-4c0d...@k30g2000hse.googlegroups.com...
Best regards,
Francesc
Raymond, you are joking aren't you, what about <<DEPTH ->LIST
sigmaLIST ???
cheers,
reth
I like that !
Can you have some other statistics in the same way ? (Average,
variance, sum of squares, etc )
Can stack be a sigmaDATA set to do it ?.
Thanks.
Daniel
yes, that's more elegant, of course.
Actually I never used sigmaLIST, so I didn't have that in mind;-)
However to get the same result as my discrete code,
with the stack contents retained,
it would look like this UserRPL snippet:
DEPTH ->LIST DUP LIST-> 1 + ROLL sigmaLIST
Not very memory-efficient, as most of the list manipulation functions.
In SysRPL, this could have been solved by the following snippet:
DEPTH {}N DUP >R INNERCOMP DROP R> 'EvalNoCK: sigmaLIST
Cheers
Raymond
> Hi,
>
> DEPTH ->LIST
> DUP LIST->
> 1 SWAP
> START
> +
> NEXT
Better is
\<< DEPTH \->LIST 0 + \GSLIST \>>
where \<<, and \>> are the program delimiters,
\-> is the right arrow symbol and
\GS is the upper case Greek 's', or sigma, symbol.
The only purpose of the " 0 + " is to allow you to use the program on an
empty stack without getting an error message. And that sum will , of
course, be 0.
Question: What is the difference between UserRPL and SysRPL ???
I did a search on the manual, and per the manual UserRPL is the
program language enclosed by << >> ; I did a search on SysRPL (Find
function) and nothing came up ??? There must be some difference.. ?
Thanks.
> Question: What is the difference between
> UserRPL and SysRPL ???
UserRPL is a subset of SysRPL.
The difference is that each UserRPL contains check-code for argument
validation which leads to a significant speed penalty as *each*
UserRPL checks for valid arguments.
The advantage is that is almost impossible to crash the calculator
while using UserRPL.
SysRPL usually does not contain any error checking so the programmer
is responsible that his program will not fail. If it fails the result
will be a warmstart (in the less severe errors) or a complete memory
wipe out.
Below SysRPL is Saturn assembly which is the fastest (in the Saturn
world, in the ARM based machines ARM assembly is way faster than
Saturn assembly as the Saturn processors is emulated in this machines)
but here you have to do *everything* by youself since your are working
outside of the operating system.
Do a search on SysRPL in this newsgroup and more answers will show up
then you can read.
HTH,
Andreas
http://www.software49g.gmxhome.de
> what about \<< DEPTH \->LIST \GSLIST \>> ???
Try it with a stack depth of either zero or one ;-)
Whatever program you use, an additional thought
is to return the NEGative of the actual sum,
with an identifying "tag" (e.g. NEG "-Sum" \->TAG)
You can then keep any number of independent sums on the stack,
simulating one of those long forgotten "paperless printer" calcs,
because each independent "section,"
consisting of some values followed by the negative sum,
totals zero, and thus does not affect subsequent sections.
This can go slightly awry if the sets of values
have many significant digits, and also
widely differ in exponent range (powers of 10),
where a "small" roundoff error in an earlier "section" can then
start off a new "section" with a relatively large "imbalance,"
but it will generally work fine for everyday accounting.
If you want to be able to insert non-numeric items
(e.g. heading strings like "Gas" "Food" etc. for your expense report)
then also have your program bypass non-numerics while summing.
E.g. here's a complete program for all HP48/49/50,
accepting any stack,
permitting multiple independent sums on the same stack:
\<< 0 DEPTH 1. SWAP FOR i i PICK DTAG
{ 0. 28. } OVER TYPE POS { + } { DROP } IFTE
NEXT NEG "-Sum" \->TAG \>> '\GSSTK' STO
This handles empty and 1-item stacks, too.
---
"Texas Instruments Paperless Printer" (1987-1996+)
http://www.datamath.org/Desktop/PaperlessPrinter.htm
http://www.datamath.org/Desktop/ti-5038.htm
http://www.datamath.org/Desktop/ti-5028.htm
[r->] [OFF]
the original post defines pretty clearly what's needed:
"...trick to calculate the sum of all the existing values of the stack
so I can avoid the use of the plus key all the time..."
and the short answer is what I sugested; all the rest is an
overkill ;)
So, how many times does one have to hit the plus key to get the sum of
zero or one values? :)
cheers,
reth
> the original post defines pretty clearly what's needed...
> all the rest is an overkill ;)
Most people have low initial expectations,
and can make do with any old calculator;
the entire HP line is "overkill,"
giving more capability, often appreciated
by those who didn't even know that they could get more.
If you object to seeing "added value,"
read a more dumbed down newsgroup ;)
-[ ]-
"the entire HP line is "overkill," I like that :)
cheers,
reth