[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

set operations on array of hash

scooterm@hotmail.com

1/15/2008 7:13:00 PM

var1 = [
{'color'=>'blue','shape'=>'round','flavor'=>'sweet'}, ## 1a
{'color'=>'yellow','shape'=>'oblong','flavor'=>'sweet'},## 1b
{'color'=>'red','shape'=>'round','flavor'=>'tart'}, ## 1c
];

var2 = [
{'color'=>'orange','shape'=>'round','flavor'=>'tangy'}, ## 2a
{'color'=>'red','shape'=>'round','flavor'=>'tart'}, ## 2c
];

puts var1.union(var2); ## (1a..2a)
puts var1.intersect(var2); ## (1c)
puts var1.notin(var2); ## (1a,1b)

Assuming you have two variables v1 and v2 declared as above,
is there a way to use the set operations of ruby to do set operations
where the elements of the "set" are each a hash?

The assumption is two elements are equal iff they both have the
exact same keys and the exact same values for those keys.

The naive approach of just using "require set" and applying ordinary
set operations doesn't seem to work.
4 Answers

Paul Stickney

1/16/2008 2:13:00 AM

0

I know this doesn't directly answer your question, but see:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-...

Also, check out the follow-up reply.

Sam Taylor

2/20/2009 11:19:00 AM

0

Mel Rowing wrote:
> On Feb 20, 7:44 am, MikeinCam...@aol.com wrote:
>> On 19 Feb, 10:22, "Chris X" <Chris_X2...@yahoo.co.uk> wrote:
>>
>>> They are well known for giving citizenship and sanctuary to all manner of
>>> hucksters and shysters ....
>>> Strange. It really *is* !
>>> ********************http://www.nowarfor...
>> Where is Lady Porter these days?
>
> If she's any sense she's tucked up in a villa somewhere.
>
> She stole not one penny.
>
> her crime was to direct housing in Westminster away from those who
> couldn't afford it and thus became a drain on the taxpayer, towards
> those who could and as a consequence were taxpayers.

Her crime was to use taxpayers money to rig elections.

> She was "fined" ?27m a sum she was not prepared to afford. She
> therefore buggered off. Rich people do not remain rich on the whim of
> the public auditor.
>
> In her place I would have done just the same.

Like house homeless families in asbestos riddled tower blocks?

Mel Rowing

2/20/2009 4:52:00 PM

0

On Feb 20, 11:18 am, Sam Taylor <b2rcco@deletethisbit_btopenworld.com>
wrote:
> Mel Rowing wrote:

> Her crime was to use taxpayers money to rig elections.

No she didn't!

You "rig" an election by placing fraudulent votes in a ballot box or
something. She did nothing like that.

Whilst it is true that those who meet their own living expenses and
pay taxes as opposed to live off benefits are more likely to vote
Tory, nobody can ever know for certain how a particular individual
votes and there are some very rich socialists around. I'm not aware of
any piss poor Tories.

It was an allegation of gerrymandering that was made against Lady P.
in that the importation of large numbers of upwardly mobile people
favoured Tory electoral prospects.

This was no doubt true as far as it goes but does not constitute a
motive in itself but we hear no such suggestion of the placement of
huge council estates within leafy suburbs of towns and neighbouring
villages where of course the very reverse was the case.

You should be aware, if you are not already that the transfer of huge
tranches of public/social housing to occupiers and private owners was
government policy at that time. It is a policy that has subsequently
been hailed as constituting the largest redistribution of wealth ever.


> > She was "fined" £27m a sum she was not prepared to afford. She
> > therefore buggered off. Rich people do not remain rich on the whim of
> > the public auditor.
>
> > In her place I would have done just the same.
>
> Like house homeless families in asbestos riddled tower blocks?

Let's not forget the state of public housing at the time. It was in
the days of dominance of "Looney left" fiefdoms in our major cities
and larger towns. It was the day of "Degsy" in Liverpool his
equivalent in Tower Hamlets. It was the days when much of the older
(and some not so old) public housing stock was falling into
dereliction. The sector was in a dire state of underinvestment not
least because of huge rent arrears which were periodically forgiven
and written off. It was virtually impossible to be evicted from a
council house for any reason let alone for arrears of rent. There were
areas where rent collectors dared not venture. Vacated properties
often freed of the burden of rent fell into the hands of "agents" who
sublet them (they collected their rents!) Vacated houses/flats would
be unofficially knocked into one another to form bigger units.

Whole estates became nests of crime and corruption.

Has everyone forgotten the state of public housing in the 70's and
early 80's? Why is it that these days, councils don't run housing
departments supported by huge subsidies and instead the money is
channelled through housing associations, the local council taking on a
more distant role?


Mel Rowing

2/20/2009 5:14:00 PM

0

On Feb 20, 4:57 pm, "Chris X" <Chris_X2...@yahoo.co.uk> wrote:
> "Alang" <inva...@invalid.co.uk> wrote in message
>
> news:3sjtp4loqrqnripvqedl8oembihtja8tfa@4ax.com...
>
>
>
> > On Fri, 20 Feb 2009 00:12:46 -0800 (PST), Mel Rowing
> > <mel.row...@btinternet.com> wrote:
>
> >>On Feb 20, 7:44 am, MikeinCam...@aol.com wrote:
> >>> On 19 Feb, 10:22, "Chris X" <Chris_X2...@yahoo.co.uk> wrote:
>
> >>> > They are well known for giving citizenship and sanctuary to all manner
> >>> > of
> >>> > hucksters and shysters ....
>
> >>> > Strange. It really *is* !
>
> >>> > ********************http://www.nowarfor...
>
> >>> Where is Lady Porter these days?
>
> >>If she's any sense she's tucked up in a villa somewhere.
>
> >>She stole not one penny.
>
> > She gained power as the result of unlaful actions
> > She stole money from the taxpayer. Keeping homes empty and secured for
> > months or years cost local taxpayers a lot of money.
> > She was found guilty in the highest court in the land
> > She and her co conspiritors were ordered to repay the estimated losses
> > of 27 million pounds
>
> >>her crime was to direct housing in Westminster away from those who
> >>couldn't afford it and thus became a drain on the taxpayer, towards
> >>those who could and as a consequence were taxpayers.
>
> >>She was "fined" £27m a sum she was not prepared to afford. She
> >>therefore buggered off. Rich people do not remain rich on the whim of
> >>the public auditor.
>
> >>In her place I would have done just the same.
>
> > So as well as being a parasite on the more productive members of
> > society you are intending to turn to crime ?
>
> LOL !   Couldn't have put it better myself !  :-)

In that case he should re-write it!