cancel
Showing results for 
Search instead for 
Did you mean: 
Erazer
Level 2
10 6 1 1
Message 1 of 8
1,178
Flag Post

Solved!

RPL: how to DELETE between two lists

HP Recommended
HP50g

Hi,

 

I have a list of names in stack row 2 like that:

{ Joe Pete Rick Sam Andy }

 

And I have a list of to be deleted names in stack row 1 like this:

{ Rick Andy }

 

I want the result in a list like this:

{ Joe Pete Sam }

 

How can I solve this with RPL?

 

Thanks !!!

0 Kudos
Tags (1)
7 REPLIES 7
BartdB
Level 9
971 954 119 186
Message 2 of 8
Flag Post
HP Recommended

Hi,

 

I suggest you look at the SUB command in section 3 of the AUR (Advanced User's Reference).

(numbered page 3-242 or physical page 362)

 

AUR is available here:

http://h10032.www1.hp.com/ctg/Manual/c02836298.pdf

 

 

Best regards.

-Bart
_________________________________________________________
calculator enthusiast
0 Kudos
Erazer
Author
Level 2
10 6 1 1
Message 3 of 8
Flag Post
HP Recommended

Hi Bart,

 

thanks for your support, but this does not work, as I have no start- and endposition.

The trick is: I need to delete the variables wherever they are in my target-list.

 

regards, Frank

0 Kudos
calcpeace
Level 4
54 54 7 7
Message 4 of 8
Flag Post
HP Recommended

Hello Frank,

 

it seems to me, you already have invested some time in solving this problem. Maybe you show your investigations (program, or fragment of a program) to us, so our help can be more goal-driven. If speed isn't a problem the brutal force way is:

make two lists out of your vectors, and then compare  every element of source list with every element of the blacklist. If the comparision failed, take it in result list otherwise not.

 

Regards

Calcpeace

0 Kudos
Erazer
Author
Level 2
10 6 1 1
Message 5 of 8
Flag Post
HP Recommended

Hi,

 

solved by myself !

The command 'Delete' which comes along with the Library 'GoferLists 1.0' handles the job:

 

{ Joe Pete Rick Sam Andy } 'Rick' Delete 'Andy' Delete

results in 

{ Joe Pete Sam }

 

Thanks for your support, appreciate

regards, Frank

Tags (1)
David_M
Level 6
140 139 29 60
Message 6 of 8
Flag Post
HP Recommended

EDIT: I was typing up this reply before I saw your post about GoferList's Delete command.  Since you have that installed, I would also suggest you take a look at Diff.

 

There are many valid approaches to solving a problem like this, including a single command from the GoferLists library that would be very useful so long as there are no repeats in the source list.

 

It seems that you are interested in learning to use RPL programming to solve problems like this, though, so I would recommend that you first give it a try on your own.  Since you already indicated in another thread that you need assistance with looping structures, I'll try to start you off with a framework that you can build upon:

 

 

«
  { } → targets result
  «
    LIST→
    1 SWAP START
      @ either move the current element to the result, or just drop it
@ (fill in your own code here) NEXT @ leave the result on the stack at completion result » »

 

Notes about the above program:

 

  • Lines that start with "@" are comments, and don't contain any executable code.  They are simply there as hints.
  • Two local variables are used (targets and result).  targets takes on the value that is already in stack level 1 when the program is invoked, and result is initialized to an empty list.
  • This program assumes that you will build the result list within the START/NEXT loop, thus leaving the final result list on the stack after the loop is complete.
  • The most important part of the program is what happens within the START/NEXT loop.  I've left that for you to fill in however you like.  Some hints: IF-THEN-ELSE-END, POS, DROP, +, STO are all commands that could be very useful here.  There's others as well, though.  It's up to you to decide what to do.

This framework supports one particular approach to a solution, and I'm not suggesting that it is the only (or even best) way to do it.  It is relatively straightforward, though.  Give this a try, and let us know if you have questions.

Erazer
Author
Level 2
10 6 1 1
Message 7 of 8
Flag Post
HP Recommended

Hey David,

 

thanks for your response. Diff is even cooler than Delete, wow.

Also thanks for your START-NEXT-Loop.

I will definately dive into it, but with weekend ahead it will take a few days.

 

Enjoy weekend

take care

regards, Frank

0 Kudos
Maké
Level 9
3,551 3,490 180 541
Message 8 of 8
Flag Post
HP Recommended

You can see, many global variables, what serve for you, in special, the Lists, from ... https://www.hpcalc.org/details/1691

 

List.JPG

 

This global variables, are created, for HP48 series, but serve too, for HP49G series and HP50G series.

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
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