ID:179095
 
Is there a simple way to combine the contents of two lists without including any member twice? Also, is there a simple way to check if the same thing occurs in two different lists? Thanks in advance!
Hmm... I should tinker with this a bit. If and when I figure something out, I'll get back to you. In the meantime, I wonder if Deadron does not have some procedure for this... or, maybe somebody else does.

-Lord of Wate
In response to Lord of Water
Lord of Water wrote:
[snip]
In the meantime, I wonder if Deadron does not have some procedure for this... or, maybe somebody else does.
[snip]

I think a few people have written something like this at one point.

I'm working on putting this into ListHelp soon so that libraries have something to link to instead of multiplying implementations. However, ListHelp has not had time to be accepted (or rejected) yet. (I just uploaded an old version _without_ this proc recently. id:66865 )

If someone else has an implementation already in a library, I'll take mine out. Multiplying code is what I'm trying to avoid in theory.

[edit]
ListHelp has been updated with a proc to help with removing multiple occurances.
In response to ACWraith
mob
proc
Combine_Lists(var/list/L1,var/list/L2)
for(var/V in L1)
if(!L2.Find(V))
L2.Add(V)
return L2

This would put everything in L1 into L2 but skip over any duplicates.

mob
proc
Compare_Lists(var/list/L1,var/list/L2)
for(var/V in L1)
if(L2.Find(V))
world << "[V] is in L1 and L2!"

That would tell you when something is in both lists.

I just made these up so they aren't in any library of mine, I can't speak for others though.