Post Reply 
(50g) Removing Objects From Lists Quickly
01-07-2019, 08:05 PM
Post: #4
RE: (50g) Removing Objects From Lists Quickly
(01-07-2019 05:19 PM)John Keith Wrote:  From my (limited) understanding of set theory, the difference function (as well as intersection and, of course, union) should eliminate any duplicates. Set functions on the Prime and in Mathematica work this way.

I'm not even remotely a mathematician, so I'll take your word for it that removing duplicates is the correct way to go. Python sets don't even allow duplicates to begin with, so you could also include that as another reference supporting that premise.

(01-07-2019 05:19 PM)John Keith Wrote:  Along those lines, I also came up with a similar program for set intersection. It is also much faster than GoferLists' Intersect and never returns lists with duplicate objects:

Code:

\<< SWAP DUP ROT LSORT LGRP DUP HEAD UNROT PICK3 OVER SIZE LMRPT LREPL SWAP MPOS LPICK LDDUP
\>>

The order of commands may seem strange but gives correct results faster than any other program I could come up with. Others are encouraged to improve the code, and especially to test it for correctness.

Once again, an interesting approach. You are indeed creative!

I've got some ideas for implementations of Union/Difference/Intersection that involve parts of the underlying code behind LDDUP/LREPL/LRMOV. I'll add that investigation to my stack of "look at this sometime" items. Those would seem to be useful and a natural fit for ListExt.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (50g) Removing Objects From Lists Quickly - DavidM - 01-07-2019 08:05 PM



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