[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: For loops don't count down

Yukihiro Matsumoto

2/19/2007 5:59:00 PM

Hi,

In message "Re: For loops don't count down"
on Tue, 20 Feb 2007 02:45:27 +0900, Daniel Schierbeck <daniel.schierbeck@gmail.com> writes:

|Is there a necessity for a range such as 5..0 to be empty?

5..1 is the easiest case, but what if "abz".."abc" where we couldn't
define reasonable String#pred. Just raise error?

I'd rather swap start and end for each operation, if empty iteration
is not wanted, until we have reverse iteration for generic case.

matz.

10 Answers

Robert Dober

2/19/2007 7:08:00 PM

0

On 2/19/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: For loops don't count down"
> on Tue, 20 Feb 2007 02:45:27 +0900, Daniel Schierbeck <daniel.schierbeck@gmail.com> writes:
>
> |Is there a necessity for a range such as 5..0 to be empty?
>
> 5..1 is the easiest case,
No it is not, how could we distinguish between a "reversed" range and
an "empty" range.
but what if "abz".."abc" where we couldn't
> define reasonable String#pred. Just raise error?
With all due respect if we have a reasonable String#succ we can define
a reasonable String#pred.
>
> I'd rather swap start and end for each operation, if empty iteration
> is not wanted, until we have reverse iteration for generic case.
>
> matz.
>
>
Cheers
Robert

--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important things.
-Anonymous

dblack

2/19/2007 7:24:00 PM

0

Robert Dober

2/19/2007 7:31:00 PM

0

On 2/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:
> Hi --
>
> On Tue, 20 Feb 2007, Robert Dober wrote:
>
> > On 2/19/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> >> Hi,
> >>
> >> In message "Re: For loops don't count down"
> >> on Tue, 20 Feb 2007 02:45:27 +0900, Daniel Schierbeck
> >> <daniel.schierbeck@gmail.com> writes:
> >>
> >> |Is there a necessity for a range such as 5..0 to be empty?
> >>
> >> 5..1 is the easiest case,
> > No it is not, how could we distinguish between a "reversed" range and
> > an "empty" range.
> > but what if "abz".."abc" where we couldn't
> >> define reasonable String#pred. Just raise error?
> > With all due respect if we have a reasonable String#succ we can define
> > a reasonable String#pred.
>
> See the thread starting at ruby-talk 38910 for an earlier discussion
> of this. It's not easy, and it's arbitrary and of questionable
> usefulness. (I don't think ranges need to be any more array-like than
> they already are -- possibly less.)

I do not like the lack of symmetry it just feels not right.
I have mixed feelings about String#succ (can be convenient for sure
and very confusing too).
It is no good though to say String#pred will be the same mess, well
than let us remove String#succ too (unfortunately I guess that would
brake too much code.)
I'd like to have a look at the thread though (long time ago, or did I
miss it?) only that the N° is not really good enough for me to find
it.

Sorry if I am the nasty guy again :(

Cheers
Robert


>
>
> David
>
> --
> Q. What is THE Ruby book for Rails developers?
> A. RUBY FOR RAILS by David A. Black (http://www.manning...)
> (See what readers are saying! http://www.r.../r...)
> Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
> A. Ruby Power and Light, LLC (http://www.r...)
>
>


--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important things.
-Anonymous

SonOfLilit

2/19/2007 7:37:00 PM

0

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

It's really easy: compose
'http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-... <<
n.to_s

or google for "ruby-talk " << n.to_s

On 2/19/07, Robert Dober <robert.dober@gmail.com> wrote:
> On 2/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:
> > Hi --
> >
> > On Tue, 20 Feb 2007, Robert Dober wrote:
> >
> > > On 2/19/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> > >> Hi,
> > >>
> > >> In message "Re: For loops don't count down"
> > >> on Tue, 20 Feb 2007 02:45:27 +0900, Daniel Schierbeck
> > >> <daniel.schierbeck@gmail.com> writes:
> > >>
> > >> |Is there a necessity for a range such as 5..0 to be empty?
> > >>
> > >> 5..1 is the easiest case,
> > > No it is not, how could we distinguish between a "reversed" range and
> > > an "empty" range.
> > > but what if "abz".."abc" where we couldn't
> > >> define reasonable String#pred. Just raise error?
> > > With all due respect if we have a reasonable String#succ we can define
> > > a reasonable String#pred.
> >
> > See the thread starting at ruby-talk 38910 for an earlier discussion
> > of this. It's not easy, and it's arbitrary and of questionable
> > usefulness. (I don't think ranges need to be any more array-like than
> > they already are -- possibly less.)
>
> I do not like the lack of symmetry it just feels not right.
> I have mixed feelings about String#succ (can be convenient for sure
> and very confusing too).
> It is no good though to say String#pred will be the same mess, well
> than let us remove String#succ too (unfortunately I guess that would
> brake too much code.)
> I'd like to have a look at the thread though (long time ago, or did I
> miss it?) only that the N° is not really good enough for me to find
> it.
>
> Sorry if I am the nasty guy again :(
>
> Cheers
> Robert
>
>
> >
> >
> > David
> >
> > --
> > Q. What is THE Ruby book for Rails developers?
> > A. RUBY FOR RAILS by David A. Black (http://www.manning...)
> > (See what readers are saying! http://www.r.../r...)
> > Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
> > A. Ruby Power and Light, LLC (http://www.r...)
> >
> >
>
>
> --
> We have not succeeded in answering all of our questions.
> In fact, in some ways, we are more confused than ever.
> But we feel we are confused on a higher level and about more important things.
> -Anonymous
>
>

dblack

2/19/2007 8:30:00 PM

0

Robert Dober

2/19/2007 9:26:00 PM

0

On 2/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:
> Hi --
>
> On Tue, 20 Feb 2007, Robert Dober wrote:
>
> > On 2/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:
> >> Hi --
> >>
> >> On Tue, 20 Feb 2007, Robert Dober wrote:
> >>
> >> > On 2/19/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> >> >> Hi,
> >> >>
> >> >> In message "Re: For loops don't count down"
> >> >> on Tue, 20 Feb 2007 02:45:27 +0900, Daniel Schierbeck
> >> >> <daniel.schierbeck@gmail.com> writes:
> >> >>
> >> >> |Is there a necessity for a range such as 5..0 to be empty?
> >> >>
> >> >> 5..1 is the easiest case,
> >> > No it is not, how could we distinguish between a "reversed" range and
> >> > an "empty" range.
> >> > but what if "abz".."abc" where we couldn't
> >> >> define reasonable String#pred. Just raise error?
> >> > With all due respect if we have a reasonable String#succ we can define
> >> > a reasonable String#pred.
> >>
> >> See the thread starting at ruby-talk 38910 for an earlier discussion
> >> of this. It's not easy, and it's arbitrary and of questionable
> >> usefulness. (I don't think ranges need to be any more array-like than
> >> they already are -- possibly less.)
> >
> > I do not like the lack of symmetry it just feels not right.
>
> You should adopt my Ruby slogan:
>
> Ruby: the triumph of balance over symmetry.
>
> :-)
It's easy when you are with the majority, do you remember the thread
about "receiver" though ;) [ I still think you are right about that
one]
I kind of hope to be right with this one, but I am checking the thread now.
Cheers
Robert
>
>
> David
>
> --
> Q. What is THE Ruby book for Rails developers?
> A. RUBY FOR RAILS by David A. Black (http://www.manning...)
> (See what readers are saying! http://www.r.../r...)
> Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
> A. Ruby Power and Light, LLC (http://www.r...)
>
>


--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important things.
-Anonymous

Robert Dober

2/19/2007 9:32:00 PM

0

On 2/19/07, Robert Dober <robert.dober@gmail.com> wrote:
> On 2/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:
> > Hi --

> It's easy when you are with the majority, do you remember the thread
> about "receiver" though ;) [ I still think you are right about that
> one]
> I kind of hope to be right with this one, but I am checking the thread now.
> Cheers
> Robert

Done.
But did you check it out?
Two facts:
It is 5 years old, and Matz said that Integer#prev was maybe not a good idea.
5 years later he has changed his mind and accepted the RCR about Integer#pred.

And I am not at all talking about that!!!

Am I as confusing as confused? [Gotta change the signature I guess]

Well just forget it for now I might have messed this thread up...

Cheers
Robert
> >
> >
> > David
> >
> > --
> > Q. What is THE Ruby book for Rails developers?
> > A. RUBY FOR RAILS by David A. Black (http://www.manning...)
> > (See what readers are saying! http://www.r.../r...)
> > Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
> > A. Ruby Power and Light, LLC (http://www.r...)
> >
> >
>
>
> --
> We have not succeeded in answering all of our questions.
> In fact, in some ways, we are more confused than ever.
> But we feel we are confused on a higher level and about more important things.
> -Anonymous
>


--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important things.
-Anonymous

dblack

2/19/2007 9:36:00 PM

0

Robert Dober

2/19/2007 9:45:00 PM

0

On 2/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:
> Hi --
>
> On Tue, 20 Feb 2007, Robert Dober wrote:
>
> >> > I do not like the lack of symmetry it just feels not right.
> >>
> >> You should adopt my Ruby slogan:
> >>
> >> Ruby: the triumph of balance over symmetry.
> >>
> >> :-)
> > It's easy when you are with the majority, do you remember the thread
> > about "receiver" though ;) [ I still think you are right about that
> > one]
> > I kind of hope to be right with this one, but I am checking the thread
> > now.
>
> One example is:
>
> "09".succ # => "10"
> "9".succ # => "10"
I thought it was "a" :(
>
> "10".pred # => ??
It would have been "09"
This is bad and there is no solution, good point again.
I guess I will deprecate String#succ in my programs
Thx for explaining it to me.
>
> Since it's not a one-to-one mapping, the only way to go backwards is
> to come up with arbitrary rules. That doesn't mean it's a bad idea,
> but there's definitely no single clear way for it to work.
>
>
> David
>
> --
> Q. What is THE Ruby book for Rails developers?
> A. RUBY FOR RAILS by David A. Black (http://www.manning...)
> (See what readers are saying! http://www.r.../r...)
> Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
> A. Ruby Power and Light, LLC (http://www.r...)
>
>
Robert

--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important things.
-Anonymous

SoHillsGuy

6/7/2012 9:38:00 PM

0


> "First time in 40 years"?!? Presumably they're meaning action figures,
> because I've got a few vehicles with "likenesses" of Batman, Robin,
> Penguin, etc. ... they're old, but not 40 years old.


Yes, but do they exactly resemble Adam West, Burt Ward and Burgess Meredith? I think that's where these will be different.