HP-25/SR-56 Identical Conditionals
10-14-2021, 07:51 PM
Post: #16
 Dave Britten Senior Member Posts: 2,321 Joined: Dec 2013
RE: HP-25/SR-56 Identical Conditionals
(10-14-2021 06:02 PM)Valentin Albillo Wrote:  Look, Dave, what you've given above is not an example of actual non-contrived code using the DSNZ function, you've just given an Owner's Handbook-style code bit picturing what it does.

I don't mean to play games with you, what I want is some sample code which does something non-contrived that shows the alleged "usefulness" and "cleanness" afforded by this DSNZ instruction, let's say similarly to how a simple implementation of the factorial function does clearly demonstrate the usefulness of the regular DSZ instruction.

Can you provide it, yes or no ?

Thanks and regards.
V.

Have you never needed to write a "for" or "while" loop where you break in the middle of the loop body instead of at the physical end of it? That's where this sort of thing would come in handy now and then.

For the sake of example, here's a cumulative (lower tail) binomial distribution program for 15C. Store n in R1, P in R2, and X in R3, then GSB A.

Code:
LBL A 0 STO 4 STO 5 RCL 2 1 STO+ 3 RCL- 2 / STO 6   // P/(1-P) LST x RCL 1 y^x     // B(n, 0, P) = (1-P)^n LBL 1 STO+ 5  // Add to cumulative probability /**** LOOP EXIT TEST ****/ DSE 3   // Decrement loop counter GTO 0 GTO 9   // Break from loop if counter was zero LBL 0 /**** END OF LOOP EXIT ****/ RCL 1   // Calculate B(n, r+1, P)... RCL 4   // B(n, r+1, P) =  -       //     B(n, r, P) * (n-r)/(r+1) * P/(1-P) RCL 4 1 + STO 4 / RCL* 6 *       // Done calculating next term GTO 1   // Do another loop LBL 9 RCL 5   // Display total RTN

With a hypothetical DSNE (decrement and skip if not less than or equal), the loop exit condition could be shortened by removing the extra GTO and LBL:

Code:
LBL A 0 STO 4 STO 5 RCL 2 1 STO+ 3 RCL- 2 / STO 6   // P/(1-P) LST x RCL 1 y^x     // B(n, 0, P) = (1-P)^n LBL 1 STO+ 5  // Add to cumulative probability /**** LOOP EXIT TEST ****/ DSNE 3   // Decrement loop counter GTO 9   // Break from loop if counter was zero /**** END OF LOOP EXIT ****/ RCL 1   // Calculate B(n, r+1, P)... RCL 4   // B(n, r+1, P) =  -       //     B(n, r, P) * (n-r)/(r+1) * P/(1-P) RCL 4 1 + STO 4 / RCL* 6 *       // Done calculating next term GTO 1   // Do another loop LBL 9 RCL 5   // Display total RTN
 « Next Oldest | Next Newest »

 Messages In This Thread HP-25/SR-56 Identical Conditionals - Matt Agajanian - 10-11-2021, 10:43 PM RE: HP-25/SR-56 Identical Conditionals. - Gene - 10-12-2021, 12:44 AM RE: HP-25/SR-56 Identical Conditionals. - Dave Britten - 10-12-2021, 01:52 PM RE: HP-25/SR-56 Identical Conditionals. - Gene - 10-12-2021, 03:05 PM RE: HP-25/SR-56 Identical Conditionals. - Valentin Albillo - 10-12-2021, 04:29 PM RE: HP-25/SR-56 Identical Conditionals. - Matt Agajanian - 10-12-2021, 06:20 PM RE: HP-25/SR-56 Identical Conditionals. - Valentin Albillo - 10-14-2021, 01:16 AM RE: HP-25/SR-56 Identical Conditionals. - Dave Britten - 10-14-2021, 11:38 AM RE: HP-25/SR-56 Identical Conditionals. - Valentin Albillo - 10-14-2021, 12:38 PM RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021, 04:18 PM RE: HP-25/SR-56 Identical Conditionals - Valentin Albillo - 10-14-2021, 04:49 PM RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021, 05:00 PM RE: HP-25/SR-56 Identical Conditionals - Valentin Albillo - 10-14-2021, 06:02 PM RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021 07:51 PM RE: HP-25/SR-56 Identical Conditionals - Valentin Albillo - 10-14-2021, 09:33 PM RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021, 09:36 PM RE: HP-25/SR-56 Identical Conditionals. - Matt Agajanian - 10-12-2021, 06:13 PM RE: HP-25/SR-56 Identical Conditionals. - Gene - 10-12-2021, 05:54 PM

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