From: Robert Klemme Date: 2006-05-17T00:14:18+09:00 Subject: Re: In search of elegant indices searching 2006/5/16, Nuralanur@aol.com : > Dear all, > > I have a Hash, with equal-length Arrays as values, something like > > my_hash={'x',[1,1,3,1,5,6],'w',[1,2,3,1,4,5],'y',[1,1,1,4,4,6],'z',[0,1,1,2,3, > 4]} . > > Some of the values in the Arrays occur several times. > Now, I am looking for an elegant way to extract, for all the values > of specified keys, all the indices > where one or more variables do not change their values, i.e., something > like > > class Hash > def fixed_vars(which_vars) > > # some elegant code > return result > end > end > > res=my_hash.fixed_vars(['x','w']) > > giving > > res={{'x'=>1,'w'=>1}=>[0,3],{'x'=>3,'w'=>3}=>[2],{'x'=>5,'w'=>4}=>[4],{'x'=>6, > 'w'=>5}=>[5]}. That's a really wired output. Can you explain what that means? I have a hard time detecting the pattern here. robert