Post Reply 
[VA] HP-71B Mini-challenge: Qualifying for a job
09-22-2022, 08:11 AM
Post: #29
RE: [VA] HP-71B Mini-challenge: Qualifying for a job
A few more comments about the challenge:

First of all, thanks Valentin for it!
At first glance, it looked easy and just a matter of optimizing a single summation operation, but clearly it was not !

Nested User-Defined-Functions (UDF)
The challenge made me realize that UDFs can be nested, for instance:
10 DEF FNF(X)
20 DEF FNG(Y)
30 FNG=X+Y
40 END DEF
50 FNF=FNG(2*X)
60 END DEF
is a valid construction on the 71B.
But there is no benefit to do so. The inner UDF is still visible from the main program, and can't access the outer UDF local parameters: X in line 30 is not the local FNF parameter, but variable X of the main program environment.
All works as if the 2 UDFs were independent.
Actually, nested UDFs are explicitly forbidden on the Technical BASIC close variants of the HP-75 and Series 80 computers.
Why is it allowed on the HP-71B? Maybe just because it was possible and doesn't harm but it's better not to use this "feature" on the HP-71B, for clarity.

Can RND be zero?
Valentin mentioned that the solution could be shorten by using CEIL(RND*6) instead of IP(RND*6+1). I also considered this option, and I too discarded it because the HP-71 reference manual states that the RND result r is 0<= r <1.
However, a close inspection of the internal working of RND shows that it is not possible to get a zero value from RND (except if RANDOMIZE 0, an uninteresting trivial case).
I will open a new topic to discuss this point in detail.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] HP-71B Mini-challenge: Qualifying for a job - J-F Garnier - 09-22-2022 08:11 AM



User(s) browsing this thread: 1 Guest(s)