[#407] New feature for Ruby? — Clemens.Hintze@...
Hi all,
27 messages
1999/07/01
[#413] Re: New feature for Ruby?
— matz@... (Yukihiro Matsumoto)
1999/07/01
Hi Clemens,
[#416] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/01
On Thu, 01 Jul 1999, Yukihiro Matsumoto wrote:
[#418] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/01
Hi
[#426] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/02
Hi,
[#427] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/02
On Fri, 02 Jul 1999, you wrote:
[#428] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/03
Hi,
[#429] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/03
On Sat, 03 Jul 1999, you wrote:
[#430] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/05
Hi,
[#431] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/07
On Mon, 05 Jul 1999, you wrote:
[#440] Now another totally different ;-) — Clemens Hintze <c.hintze@...>
Hi,
21 messages
1999/07/09
[#441] Re: Now another totally different ;-)
— matz@... (Yukihiro Matsumoto)
1999/07/09
Hi,
[#442] Re: Now another totally different ;-)
— Clemens Hintze <c.hintze@...>
1999/07/09
On Fri, 09 Jul 1999, you wrote:
[#452] Re: Now another totally different ;-)
— gotoken@... (GOTO Kentaro)
1999/07/11
Hi,
[#462] Re: Now another totally different ;-)
— matz@... (Yukihiro Matsumoto)
1999/07/12
Hello, there.
[#464] Re: Now another totally different ;-)
— Clemens Hintze <c.hintze@...>
1999/07/12
On Mon, 12 Jul 1999, you wrote:
[#467] Re: Now another totally different ;-)
— matz@... (Yukihiro Matsumoto)
1999/07/12
Hi,
[#468] Re: Now another totally different ;-)
— gotoken@... (GOTO Kentaro)
1999/07/12
In message "[ruby-talk:00467] Re: Now another totally different ;-)"
[#443] — Michael Hohn <hohn@...>
Hello,
26 messages
1999/07/09
[#444] interactive ruby, debugger
— gotoken@... (GOTO Kentaro)
1999/07/09
Hi Michael,
[#448] Re: interactive ruby, debugger
— "NAKAMURA, Hiroshi" <nakahiro@...>
1999/07/10
Hi,
[#450] Re: interactive ruby, debugger
— Clemens Hintze <c.hintze@...>
1999/07/10
On Sat, 10 Jul 1999, you wrote:
[#490] Some questions concerning GC in Ruby extensions — Clemens Hintze <c.hintze@...>
Hi matz,
6 messages
1999/07/14
[#501] Ruby 1.3.5 — Yukihiro Matsumoto <matz@...>
Ruby 1.3.5 is out, check out:
1 message
1999/07/15
[#519] CGI.rb — "Michael Neumann" <neumann@...>
Hi...
7 messages
1999/07/24
[#526] Another way for this? And a new proposal! — Clemens Hintze <c.hintze@...>
Hi,
6 messages
1999/07/25
[ruby-talk:00452] Re: Now another totally different ;-)
From:
gotoken@... (GOTO Kentaro)
Date:
1999-07-11 05:20:59 UTC
List:
ruby-talk #452
Hi,
>But I have another opinion! May I explain my reasons?
>
>1. Every class includes Enumeration can be converted to an Array via
> Enumeration#to_a. So Enumeration#[] could deliver the value which
> would correspond to the combination Enumeration#to_a and Array#[].
> E.g.:
> c = <any class import Enumeration>::new
> # ... fill c
> c[0] == c.to_a[0]
But how we should treat Hash or String? Some Enumerable classes has
its own []. For example, "abc"[1] != "abc".to_a[1].
By the way, Matz, why the following doesn't print "b\n" but 10?
module Indexed
def [](n)
to_a[n]
end
end
class String
include Indexed
end
if __FILE__
p "abcdefg".gsub(/./,"\\&\n")[1]
end
>3. I have not thought very deeply, but I would think, that every class
> which provides an `each' method, would define a certain kind of
> sequence then! I don't believe that there would be a class, which
> would deliver different sequences during two successive calls of
> e.g. Enumeration#collect. That means:
> c = <any class import Enumeration>::new
> # ... fill c
> a1 = c.collect{|e| e}
> a2 = c.collect{|e| e}
> a1 == a2
I don't agree it. Because we can define a class which has `each' but
`collect'. A typical case is potentially infinitely many sequence.
For example, an mathematical sequence
class Trajectory
def initialize(init, &map)
@init = init
@map = map
end
def each
s = @init
loop do
yield(s)
s = @map.call(s)
end
end
end
if __FILE__ == $0
chaos = Trajectory.new(0.1){|x| 4.0*x*(1.0-x)}
chaos.each{|x| break if x > 0.99999; p x}
end
In this case, the halting problem of `each' depends. You may claim
that it is NOT an example of Enumeration but I feel this `each' IS
very `each' because I think an enumeration is a *process* rather than
an *evaluation*, so it should not be restricted to something to halt.
A usage of unbounded `each' is a substitute for `while'.
By the way, I think the current problem (i.e., our frustration about
Range) came from the lack of easy way to make a subclass which is a
result of appended/modified a kind of methods: for instance,
class FloatWithSucc < Float
def succ
self + 0.3
end
end
It doesn't work because the value of succ is not FloatWithSucc. This
kind of difficulty weaken Range, maybe.
-- gotoken