[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: increasing counter whithin loop?

Kroeger, Simon (ext)

12/8/2005 9:45:00 AM


> [...]
> > A lot of Ruby's clarity comes not from being able to write things
> > clearly in the "raw" language, but from being able to easily
> > customize the language for your needs.
>
> Of course, and that is what I am asking in the whole thread! Is there
> a nicer way for this loop... Let's see. I have this each_with_next
> now, but still I am completely unstatisfied with my loop. But I am now
> convinced that I have the optimal solution, even if it the way it
> looks now. And btw., I need a look-ahead for this specific purpose.
> The each_with_previous was a very nice hint, thanks, even if I wasn't
> able to use it. I'd probably have to create each_with_prev_and_next.

Hmm, I still don't know exactly what you realy want/need. If you just
want to replace two instances of :b with double_b, have a look at this:

-----------------------------------------------------------------
require 'enumerator'
a=[:a, :b, :b, :c, :b, :d, :e]

a[a.to_enum(:each_cons, 2).to_a.index([:b, :b]), 2] = 'double_b'
puts a
-----------------------------------------------------------------

(yes, of course this is completely without error checking and
doesn't work for more than one occurrence of :b, :b)

As I said, I'm not realy sure that's what you are looking for...

cheers

Simon


1 Answer

Steve from Colorado

9/19/2012 5:02:00 AM

0

On 9/18/2012 9:08 PM, Ronald Dumsfeld wrote:
> On 9/15/2012 7:02 AM, charles bash wrote:
>> It appears to be that the Best News on immigration subjects originates
>> in Virginia.
>>
>> As of January, 2005, I reckon, The State Assembly of Virginia, and the
>> Governor,, signed into law a Comprehensive anti-illegal alien bill. No
>> State or Local Govm't benefits for illegal aliens. {{ other than
>> Mandated by Federal law }}
>>
>> The Virginia Att'y General at the time, wrote letters to all the College
>> Registrars in Virginia advising them of the new law, and Illegal aliens
>> are NOT to be Enrolled in any college in Virginia..
>>
>> Some months later,, MALDEF, no less entered suite in Federal Court in
>> Alexandria, VA., challenging the 'fairness' of the new law. MALDEF
>> presented a half dozen 'john doe' illegal alien high school graduates,
>> and demanded that they have the opportunity to enroll in a Community
>> College in northern Virginia. IIRC.
>>
>> Case was over,, {{ as I reported previously }} in 10 minutes!. The
>> Illegals, you see, had No Standing to Sue! We need more of that!.
>> ******** ******** ******** ******** ********
>>
>> Actually, the New anti-illegal alien law was not a Slam Dunk at all!!
>> The law was handed up to the Governor at the last days of the 2004
>> Legislative session. The Governor failed to sign the Bill in a prompt
>> manner. It appeared that the Bill would Die if not signed in 30 days!
>> What a rotten, cowardly strategy!
>>
>> A news article reported on this new illegal alien Bill.The Governor left
>> the Capitol in Richmond and retreated to his Mansion home in Northern
>> Virginia.
>>
>> That's when Charley Bash went into action! I was able to find the
>> Governor's Mansion home phone number from Verizon 411, and promptly
>> composed my windshield Flier, and printed up an Original.
>>
>> On the first 3 weekends of January, I visited all the major shopping
>> mall parking lots in Northern Virginia and was able to place 800 copies
>> of my windshield Flier on the parked cars there.
>>
>> My poor fingers were Freezing!, so I had to make frequent stops in any
>> fast food restaurant in the Mall to get coffee and warm up. My Flier
>> explained the Importance of the new Bill and recommended that the
>> Citizens Call the Governor at His Mansion! Urging him to Sign The Bill!
>> I included the Governor's Mansion phone number! ~ for chrissake ~
>>
>> On the LAST DAY of the 30 Day Window,, the Governor signed the No
>> -Benefits bill into Law!! Honest to God!I. I Myself made several calls
>> to the Governor's Mansion urging him to sign! They had ladies there,
>> promptly answering the Phones and who might have been State Employees!
>> Different voices answered the phone almost every time I called. So it
>> wasn't the Governor's wife!
>>
>> When all was over and done with, I made one last call to the Mansion
>> House. I politely asked.
>>
>> '>'Gosh the Governor must have had a lot of
>>> phone calls, on this new Law!, Were your
>>> phones Ringin' off The Hook? The reply. "Oh
>>> My,, Yes!!"
>>
>> That's what Activists need to do! When the occasion warrants. But we had
>> Good Citizens there too! At times Mall customers were entering their car
>> as I was placing my Flier. I saw Plenty of Fathers pick up the Flier and
>> thoughtfully read it, before entering the family car!
>> C. Bash
>>
>> ~ I remember picking up the Windshield wiper arm on a brand new
>> Mercedes. The wiper Fell Off! So I placed my Flier and replaced the
>> wiper ~ good as new. ~
>>
>
> Good job, Mr. Bash. You made a big difference. Bravo. And don't
> forget the recall campaign in California that removed traitor Gray Davis
> from the governor's office after he decided to give drivers licenses to
> illegal aliens. And don't forget Arizona, Alabama and Georgia have made
> headway against the illegal alien infestation through a variety of new
> anti-illegal immigrant laws.
>
> Ronald Dumsfeld (formerly using the nym Hisler)

A user in another usenet group suggested I just use "Steve from
Colorado" instead of a confusing new nym. Taking his advice, I have
dropped the Hisler nym and will post only as Steve from Colorado from
here on.