Stream: helpdesk (published)

Topic: Mirror dict?


view this post on Zulip Kevin Bonham (Dec 10 2021 at 14:17):

Or maybe reciprocal dict - not sure what the right name for this is, but wondering if such a data structure exists in a package somewhere. Basically, I'd like a dictionary-like structure, where all entries are reciprocal. That is,
I'd like to do something like:

md = MirrorDict('a'=>'b', 'c'=>'d')

md['a'] # 'b'
md['b'] # 'a'
md['d'] = 'e'

md['e'] # 'd'
md['c'] # key error

view this post on Zulip Timothy Larson (Dec 10 2021 at 15:08):

https://github.com/scheinerman/Bijections.jl/blob/master/README.md

view this post on Zulip Timothy Larson (Dec 10 2021 at 15:09):

Take note of the "active_inv" it can provide.


Last updated: Oct 02 2023 at 04:34 UTC