On Thursday 15 March 2001 22:17, you wrote: > > From: Charles Hixson [mailto:charleshixsn / earthhlink.net] > > ... > > > > What you want to return is a bag, not a set. So the general inverse of a > > hash would have the second element be a list of values: > > h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "e"=>200, > > "a" => 0, "k"=>100} > > h.invert #=> {200=>["d", "e"], 300=>["y"], 0=>["a"], > > 100=>["n", "k"]} > > Just, > > out of curiosity is this the way CS-types use the term bag - or this all > applied to the full-fledged thing - i.e. a general relation? > > Christoph FWIW-- I don't think of myself as exactly a CS-type, but I've been a programmer for quite awhile. However, I think the usage came out of mathematics. A bag was a set that could hold multiple copies of the same entity. Not quite what I was expressing, but I can't think of a better term. What I was returning was a hash that could hold multiple entries for the same key (which seems to me to be what you need if you want to invert a hash table). And it's a kind of a bag, if you consider the different copies of the same element in the bag to be somehow distinguishable.