Locked topic

This topic has been locked due to inactivity for a long period of time. If you have a question, please create a new topic by clicking here.
Highlighted
Intern
Intern
37 0 3
Message 1 of 7
553
Flag Post
HP Recommended

Solved!

How to make that operation with lists { } works both on RPN and Algebraic modes ?

HP 50g

Hello dear HP community , 

I wanted to know if there any way how to work and operate with lists in Algebraic calculator mode in HP 50 g graphing calculator , of course , successfully . 

I have one program and core business of this programme is done by lists . Program  is about calculating angles with an expression in which angles are entered in HMS format ( HH.MMSSSS ) under single quote algebraic expression . Normally you use programme only for subtracting or adding angles into calculation .  I hope that you understood what I mean , just program which calculates  expressions by using + in - operators in algebraic expressions .

 

So here is my code ...

LISTA.pngMy source code

And here I' will show you what happens when i type entered variables in RPN mode at that programme and result of calculation 

ULAZ_ULAZA.pngHere is entered variables in RPN mode , and remember , this is written under single ' ' quotes !!FORMULA.pngthis is a entered formula and answer to this problem

And now I will show you my results from this program into RPN mode 

REZULTAT_HMS_MODE.pngMy result in HMS mode , the programm works properly !!

And now the same programme when I run on Algebraic mode :

But before that ... entered variables ...

ULAZ_ALG_MODE.pngentered variables ( like that in equation )

and result ...

but i don't understood how on this emulator works that all ... in ALG MODE ... but physically does'not work , or it can be coincidence ?!  

REZULTAT_ALG_MODE.pngresult in ALG mode , correctly !!

Ok here is my code , and I'm not joking with you , I really does not know what is the reason for this  !!

But code is in emulator ...

kod_emulator_1_od_3.pngfirst part of my code ... in emulatorkod_emulator_2_od_3.pngsecond part of my codekod_3_od_3.pngthird part of my code but i will finish my code with ...kod_4_4.pngthe last caption of code ...

and if programme works in both calculator mode , the weird thing is that ... 

How is possible that part of code ( of this programme )  which works in RPN mode does not works in Algebraic calculator mode , i really doesn't know reason , fully coded program works , by emulator at least

 

The same code ... I will ( probably ) show you code later if I remember ,

20181122_081311.jpgyou can see program that does not work , all have been done in ALG mode ( entering variables and saving output variables and showing them ) , argumenti - represents arguments of a function , operatori - stands for operators ,20181122_081653.jpgthis is arguments good , and operators too , only plus sign as you can see , so my question is how it's possible that same thing works here in RPN mode but I decided to show you a name of variables so i get back to Algebraic modeSOURCE KOD DIJELA PROGRAMA.pngHere is source code for that programme but i tested it on HP 50g 

and of course input variable must be in form of this , first it must be a list which have elements of arguments and operators , in meaning if i have five numbers and if i want to add all theth numbers each on another my input variable stands like , or sounds like : 

{ 1 + 2  +  3  +  4  +  5 }

 

My final question is , in aware of this situation , How to perform operations with lists in ALG mode with no errors ?

Tags (1)
6 REPLIES
Grad Student
Grad Student
94 18 35
Message 2 of 7
493
Flag Post
HP Recommended

Solved!

How to make that operation with lists { } works both on RPN and Algebraic modes ?

I never use my 50g in algebraic mode, so I'm not able to comment on the differences in what you're seeing between ALG and RPN modes.  Hopefully someone else more familiar with the differences can comment on that aspect.

 

If you don't mind an alternative approach to what it appears you are attempting to do, the following might be helpful:

«
    →LST →STR
    "+" "HMS+" SREPL DROP
    "-" "HMS-" SREPL DROP
    STR→ EVAL    
»

Note that the first command is not →LIST, the lack of an "I" is intentional (and important).  It's one of the special commands available in the "Developer's Library", which you may need to attach before creating the above program.  It's built-in, but may not be available to you if it hasn't already been attached:

256 ATTACH

 

How this works

 

→LST converts an algebraic object (in this case '108.3045-127.3140+36.3542+20.0334-201.3209') into a list, which is then converted once again into a string.  Once in string form, it's easy to convert the "-" and "+" steps into what you really want them to be ("HMS-" and "HMS+", respectively).  SREPL handles those substitutions quickly and easily.  SREPL returns the number of instances of the replacements it made, and since those values aren't needed here they are simply dropped.  Finally, the resulting string is converted back into a list object with STR→, then evaluated with EVAL.

 

A couple other thoughts after looking at your program:

 

  • Boolean values in RPL are represented by numbers: 0 equates to FALSE, and any other non-zero number equates to TRUE.  This allows you to shorten constructs such as "i 2. MOD 1. ==" to simply "i 2. MOD".  NOT will change a 0 to a 1, and any non-zero number to a 0.  That may also help shorten (and speed up) your code.
  • The positional argument to GET doesn't need to be in a list.  Is there some reason I'm not seeing that you've encapsulated them that way?  I may just be misunderstanding what you're doing.
  • "3 ROLL" is the same thing as the single command ROT.  Similarly, "3 ROLLD" can be shortened to UNROT.
  • "SWAP DROP" can be shortened to **bleep**.
    (apparently the built-in command name is on a list of "naughty words", hence the "**bleep**".  Hopefully this will clarify the command I meant: "N", followed by "IP".)

These are meant merely as suggestions for simplifications that can save space (and time) in your programs.  There's nothing inherently wrong with your current approach.

Intern
Intern
37 0 3
Message 3 of 7
455
Flag Post
HP Recommended

Solved!

How to make that operation with lists { } works both on RPN and Algebraic modes ?

Hello ,

First of all - Thanks for participating into this conversation  😃

 

I'm so glad that I learned something , relative NEW for me , and your programme that you suggested to me is not that "complicated" like mine is . Thank you so much for your advices and of course - all of your explanations which is , IF I can say so professionaly done . 

 

But of course , I have question too ,  for you !!  I saw that you use SREPL function , and wonder for what need I'll be able to use that function . I never heard before , so sorry about that , and if you have explanation about syntax too , that would be nice 😄

 

Thanks a lot with all of this useful " tips and tricks" and reading my message , by the first !!

Best Regards !!

 

 

0 Kudos
Grad Student
Grad Student
94 18 35
Message 4 of 7
417
Flag Post
HP Recommended

Solved!

How to make that operation with lists { } works both on RPN and Algebraic modes ?

SREPL takes three arguments:

 

3: Source string

2: Substring to search for

1: Replacement string

 

Upon executing SREPL, each occurrence of the targeted substring (SL2) in the source string (SL3) will be replaced with the string in SL1.  The substring and replacement strings don't have to be the same size, and the replacement string can be an empty string ("") if you simply want to delete all occurrences of the targeted substring.

 

SREPL returns the modified source string in SL2, and the number of subsitutions it performed in SL1.

 

After giving this a bit more thought, I would recommend a slightly different target/replacement pair in your situation:

target: " + ", replaced with " HMS+ "
target: " - ", replaced with " HMS- "

The difference is that I've surrounded both the target and replacement strings with spaces.  I believe this is a better approach, because it is less likely to run into problems if your input happens to have values which are signed (as could occur in other applications of this technique).

 

If you're comfortable working with lists in your programs, you might want to consider installing the List Extensions (ListExt) Library.  It adds many useful list processing features to your 50g, including a command which is very convenient in this particular situation.  LREPL from that library is very similar to SREPL, using list arguments as opposed to strings.  That mitigates the need to convert the list into string form before performing the substitutions.  It also doesn't return the count of replacements, which simplifies this even further:

«
   →LST
   { + - } { HMS+ HMS- } LREPL
   EVAL
»

This version is not only smaller than the previous one, it better targets the exact functions you'd want to replace (no chance of inappropriate "-" operators being replaced) and is faster.

 

In the interest of full disclosure: I'm the author of the ListExt library, so I'm appropriately biased in my opinion of its usefulness.

Tags (1)
Intern
Intern
37 0 3
Message 5 of 7
375
Flag Post
HP Recommended

Solved!

How to make that operation with lists { } works both on RPN and Algebraic modes ?

Dear David M. ,

 

Thank you for all posts which you had done here !! This last is very very useful and I ask to myself "How do he do that ?" .

I uses list of course very much because they make your job much easier , the real note is when you try to convert multiple numbers into some useful to user , and usualy i do that with lists .

 

So , I wonder can you tell me how do you do that , I mean you create library which contains some operation with list in a simmilar way that works some functions in my HP 50g graphing calculator . So , I mean do you  have some special program's and do you must work on "higher" programming language (perhaps) too .

 

I'm so glad and tankful that you just give me an offer to use library which you created for additional operations with lists .

That offer is accepted with no any doubt about that !!

I did not realized that so much people use this HP 50g at this level of programming , that I perhaps never reached !!

In Croatia we'll said "Kapa do poda" , type that on google translate and you will figure out what I really mean , and I mean this "Good job , Professional" and in meaning of that I will accept your solution definetely to my problem 

 

 

0 Kudos
Grad Student
Grad Student
94 18 35
Message 6 of 7
356
Flag Post
HP Recommended

Solved!

How to make that operation with lists { } works both on RPN and Algebraic modes ?

So , I wonder can you tell me how do you do that , I mean you create library which contains some operation with list in a simmilar way that works some functions in my HP 50g graphing calculator . So , I mean do you  have some special program's and do you must work on "higher" programming language (perhaps) too .

In this particular case, I used a development environment called Debug4x to create the library.  Debug4x provides an IDE for developing programs that are compatible with all of the "4x" RPL calculators (both the 48 and 49 series, including the 50g).  Debug4x can be used to write standard (User) RPL programs, but you've probably already got a better product for that purpose (it appears you may be using something like HPUserEdit).

 

Debug4x's strength is in supporting the development of code written in System RPL and Saturn assembly language.  System RPL (usually written as "SysRPL") works in a similar fashion to UserRPL, but offers additional functionality and greater performance because it skips most of the built-in safety checks provided at the UserRPL level and allows direct manipulation of objects and environmental features.  This means that SysRPL programs are often better performers than their UserRPL counterparts, but the developer of the code has to ensure that all of the appropriate steps are taken to avoid crashing the calculator (which is quite easy to do with SysRPL!).  Saturn assembly language is the "lowest level" code possible on the Saturn-based calculators (all 48s and the 49G).  It is also possible to run Saturn code on the ARM-based systems, though the Saturn processor on those systems is emulated.

 

To maximize performance, the ListExt library was created entirely in SysRPL and Saturn assembly language.

 

You should also look at GoferLists.  The combination of GoferLists and ListExt gives your 50g a powerful set of commands for list processing.

0 Kudos
Distinguished Professor
Distinguished Professor
3185 144 449
Message 7 of 7
304
Flag Post
HP Recommended

Solved!

How to make that operation with lists { } works both on RPN and Algebraic modes ?

Hi!, @JKova:

1) You can solve for degrees, minutes and seconds, with this SysRPL program (without compiled), for what you see step by step, the sequences ...

: :

0LastRowWrd;

CK1&Dispatch

BINT1

: :

   %>HMS

   %5

   RNDXY

   : :

       IDUP

       DUP

       %IP

       DUP

       a%>$,

       3UNROLL

       %-

       %100

       %*

       %ABS

    ;

    a%>$,

    3UNROLL

    " ' "

    &$SWAP

    " ° "

    &$SWAP

    &$SWAP

    &$

 ;

;

@

You needed compile after for work. You can use EMACS 2.11 with Nosy or CQ1F? and extable.

2) Other method for your result ... -163.5348 ...

degrees = int(163.5348°) = 163°
minutes = int((163.5348° - 163°) × 60) = 32'
seconds = (163.5348° - 163° - 32'/60) × 3600 = 5.28"
-163.5348°
= -163° 32' 5.28"

 


You're Welcome !.
Best wishes and regards.
@Maké (Voluntary and "ad honorem").
Click the White thumb to say thanks.
Please, mark Accept As Solution if it solves your problem.
0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation