Re: Data-structure for multiway associativity in Python

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 14:48:02 -0800, qrious wrote: > First list = { 1, 2, 3} > Second list = { 4, 5, 6} > Third list = { 7, 8, 9} > > If I pass 9 as the argument, the return value of the function would be > {7, 8}. subsets = [{1, 2, 3}, {4, 5, 6}, {7, 8, 9}] data = {} for subset in subsets:

Re: Data-structure for multiway associativity in Python

2018-01-28 Thread qrious
On Sunday, January 28, 2018 at 7:00:38 AM UTC-8, Steven D'Aprano wrote: > > Since you specified that there are no lists with shared members, why > bother returning a list of lists? There will only ever be a single > matching list. > That's correct. It will be a single list. My mistake in typi

Re: Data-structure for multiway associativity in Python

2018-01-28 Thread Steven D'Aprano
On Sat, 27 Jan 2018 10:01:47 -0800, qrious wrote: > I need a data structure and a corresponding (hopefully fast) mechanism > associated with it to do the following. While I am looking for the > concept first, my preference for implementation of this will be in > Python. > > [c1, c2,..., cn] is a

Re: Data-structure for multiway associativity in Python

2018-01-27 Thread MRAB
On 2018-01-27 18:01, qrious wrote: I need a data structure and a corresponding (hopefully fast) mechanism associated with it to do the following. While I am looking for the concept first, my preference for implementation of this will be in Python. [c1, c2,..., cn] is a list of strings (for m

Re: Data-structure for multiway associativity in Python

2018-01-27 Thread Dan Stromberg
It's possible, but not common, to do association lists in Python. They're pretty inefficient in just about any language. I'm not totally clear on what you need, but it might be a good thing to do a list of sets - if you're looking for an in-memory solution. On Sat, Jan 27, 2018 at 10:33 AM, Denni

Data-structure for multiway associativity in Python

2018-01-27 Thread qrious
I need a data structure and a corresponding (hopefully fast) mechanism associated with it to do the following. While I am looking for the concept first, my preference for implementation of this will be in Python. [c1, c2,..., cn] is a list of strings (for my own implementation, but could be a