[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: handling lists in perl



On Wed, Dec 19, 2018 at 02:48:17PM -0600, David Wright wrote:
> I assume that for two numbers in the second list to be selected, both
> have to match the two members of an individual tuple. As the tuples
> are ordered, I would assume that they are to be tested in the order
> supplied.
> 
> As dictionary lookups are fast, I would convert the second list into
> a dictionary: the number as the dictionary key and the number of
> occurrences as the dictionary value. (Although the problem states
> that the second list shouldn't have duplicates, this method checks
> whether this is indeed the case.)
> 
> Scanning the list of tuples in order, it's now quick to see if both
> members are in the dictionary and, if so, decrement their values or
> delete. What survives of the dictionary keys is the unmatched numbers;
> the matched pairs can be added to a list, individually or as tuples.

Yup, this was my interpretation as well.  He's got what ought to be a
hash stored as a list, and he's got what ought to be a list of lists
stored as a hash.  And we don't know what any of it represents, or
what he wants to do with them, or WHY.

OP, you need to provide an actually readable version of the problem.
Explain what you're doing.  Tell us what your inputs ARE and where
they COME FROM and what you want to DO with them.

Ideally, give actual examples.  Not made-up bullshit examples.  REAL ones.


Reply to: