Post Reply 
Large 50g program example
06-20-2015, 04:51 AM
Post: #11
RE: Large 50g program example
(06-19-2015 01:09 PM)Claudio L. Wrote:  You could always create one single object with local variables containing all the code, like this:

Compare this program to the 3rd program of this previous post which uses directories:
Code:
\<<
  \<< ROT ROT
  \>>  \-> UNROT
  \<<
    \<<
      UNROT EVAL OVER / -2 /
      UNROT EVAL /
    \>>
    \<<
      OVER SQ SWAP - \v/
    \>>
    \<<
      DUP2 -
      UNROT EVAL +
    \>>
    \-> TRANSFORM DISCRIMINANT PLUSMINUS
    \<<
      TRANSFORM EVAL
      DISCRIMINANT EVAL
      PLUSMINUS EVAL
    \>>
  \>>
\>>

Quote:Local names are evaluated differently from global names. When a global name is evaluated, the object stored in the corresponding variable is itself evaluated.
(…)
When a local name is evaluated, the object stored in the corresponding variable is returned to the stack but is not evaluated.
- HP 48G Series User's Guide p. 29-17

Thus EVAL is sprinkled all over the program. Moreover since UNROT is used in the other subroutines it has to be defined in a surrounding local variable structure.
But I doubt that anybody is going through this hassle to define a new word from only two commands when it needs two commands to execute and even uses more letters to type.
In this case I tend to develop the program using global variables in a separate directory and inline the code once it is stable.
You can still use comments to structure the program:
Code:
\<<
  @ transform ( a b c -- p q )
  ROT ROT OVER / -2 /
  ROT ROT /

  @ discriminant ( p q -- D )
  OVER SQ SWAP - \v/

  @ plusminus ( p D -- x1 x2 )
  DUP2 - 
  ROT ROT +
\>>

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Large 50g program example - Tugdual - 06-19-2015, 05:41 AM
RE: Large 50g program example - Paul Dale - 06-19-2015, 06:25 AM
RE: Large 50g program example - Tugdual - 06-19-2015, 09:50 AM
RE: Large 50g program example - Bruno - 06-19-2015, 09:59 AM
RE: Large 50g program example - BruceH - 06-24-2015, 08:15 PM
RE: Large 50g program example - Claudio L. - 06-19-2015, 01:02 PM
RE: Large 50g program example - ttw - 06-19-2015, 06:55 AM
RE: Large 50g program example - Claudio L. - 06-19-2015, 01:09 PM
RE: Large 50g program example - Tugdual - 06-19-2015, 01:36 PM
RE: Large 50g program example - Joe Horn - 06-20-2015, 02:58 AM
RE: Large 50g program example - Thomas Klemm - 06-20-2015 04:51 AM
RE: Large 50g program example - Claudio L. - 06-23-2015, 03:49 PM
RE: Large 50g program example - fyescas777 - 07-06-2015, 02:24 AM
RE: Large 50g program example - Tugdual - 07-06-2015, 10:29 AM
RE: Large 50g program example - Hlib - 08-27-2016, 08:29 AM



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