[#5809] mod_ruby-0.0.7 — Shugo Maeda <shugo@...>

前田です。

63 messages 1999/03/01
[#5845] Re: mod_ruby-0.0.7 — Shugo Maeda <shugo@...> 1999/03/01

前田です。

[#5860] Re: mod_ruby-0.0.7 — moochan <moochan@...> 1999/03/02

moochan です.

[#5892] Re: mod_ruby-0.0.7 — Shugo Maeda <shugo@...> 1999/03/02

前田です。

[#5855] Re: mod_ruby-0.0.7 — Shugo Maeda <shugo@...> 1999/03/01

前田です。

[#5919] Re: mod_ruby-0.0.7 — Shugo Maeda <shugo@...> 1999/03/03

前田です。

[#5895] [REQ] 中置の def — EGUCHI Osamu <eguchi@...>

えぐち@エスアンドイーです。

18 messages 1999/03/02
[#5907] Re: [REQ] 中置の def — EGUCHI Osamu <eguchi@...> 1999/03/03

えぐち@エスアンドイー です。

[#5965] Re: Precision in Mathematica (Re: Bigfloat) — keiju@... (石塚圭樹 )

けいじゅ@日本ラショナルソフトウェアです.

28 messages 1999/03/04
[#5981] Re: Precision in Mathematica (Re: Bigfloat) — gotoken@... (GOTO Kentaro) 1999/03/04

ごとけん

[#6053] Re: Precision in Mathematica (Re: Bigfloat) — matz@... (Yukihiro Matsumoto) 1999/03/06

まつもと ゆきひろです

[#6150] Re: Precision in Mathematica (Re: Bigfloat) — matz@... (Yukihiro Matsumoto) 1999/03/09

まつもと ゆきひろです

[#6159] Re: Precision in Mathematica (Re: Bigfloat) — EGUCHI Osamu <eguchi@...> 1999/03/09

えぐち@エスアンドイー です。

[#6197] Re: Precision in Mathematica (Re: Bigfloat) — keiju@... (石塚圭樹 ) 1999/03/10

けいじゅ@日本ラショナルソフトウェアです.

[#6203] Re: Precision in Mathematica (Re: Bigfloat) — EGUCHI Osamu <eguchi@...> 1999/03/10

えぐち@エスアンドイー です。

[#6224] Re: Precision in Mathematica (Re: Bigfloat) — keiju@... (石塚圭樹 ) 1999/03/11

けいじゅ@日本ラショナルソフトウェアです.

[#6238] Re: Precision in Mathematica (Re: Bigfloat) — EGUCHI Osamu <eguchi@...> 1999/03/11

えぐち@エスアンドイー です。

[#6302] Re: Precision in Mathematica (Re: Bigfloat) — keiju@... (石塚圭樹 ) 1999/03/12

けいじゅ@日本ラショナルソフトウェアです.

[#6304] Re: Precision in Mathematica (Re: Bigfloat) — EGUCHI Osamu <eguchi@...> 1999/03/12

えぐち@エスアンドイー です。

[#5970] [REQ] variable of regex — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

43 messages 1999/03/04

[#6090] Thread#kill — Shugo Maeda <shugo@...>

前田です。

24 messages 1999/03/08

[#6328] Re: Ruby 1.3.1-990315 — WATANABE Hirofumi <watanabe@...>

わたなべです.

41 messages 1999/03/15
[#6329] Re: Ruby 1.3.1-990315 — matz@... (Yukihiro Matsumoto) 1999/03/15

まつもと ゆきひろです

[#6331] Re: Ruby 1.3.1-990315 — Wakou Aoyama <wakou@...> 1999/03/15

青山です。

[#6338] Re: Ruby 1.3.1-990315 — matz@... (Yukihiro Matsumoto) 1999/03/16

まつもと ゆきひろです

[#6347] Re: Ruby 1.3.1-990315 — Wakou Aoyama <wakou@...> 1999/03/16

青山です。

[#6348] Re: Ruby 1.3.1-990315 — matz@... (Yukihiro Matsumoto) 1999/03/16

まつもと ゆきひろです

[#6350] Re: Ruby 1.3.1-990315 — Wakou Aoyama <wakou@...> 1999/03/16

青山です。

[#6353] Re: Ruby 1.3.1-990315 — matz@... (Yukihiro Matsumoto) 1999/03/16

まつもと ゆきひろです

[#6354] Re: Ruby 1.3.1-990315 — Wakou Aoyama <wakou@...> 1999/03/16

青山です。

[#6434] Time#+ — Koji Arai <JCA02266@...>

新井です。

19 messages 1999/03/22
[#6442] Re: Time#+ — matz@... (Yukihiro Matsumoto) 1999/03/22

まつもと ゆきひろです

[ruby-dev:6231] Re: Incrementable

From: Shin-ichiro Hara <sinara@...>
Date: 1999-03-11 14:28:02 UTC
List: ruby-dev #6231
原です。

Incrementable で強引に Range2 と Range3 を作ってみました。

require "delegate"

class Succession < SimpleDelegator
  include Incrementable
  def inc; @obj = @obj.succ; end
end

class UpperBounded < Succession
  def initialize(first, last)
    super(first)
    @first, @last = first, last
  end
  def status; self <= @last; end
end

class Range2
  include Enumerable
  def initialize(first, last)
    @first, @last = first, last
  end
  def each(&block)
    UpperBounded.new(@first, @last).start(&block)
  end
end

# 例1
a = Range2.new(1, 5)
a.each { |x| p x } #=> 1, 2, 3, 4, 5

この Range2 自体はなにもいい所が無いのですが、UpperBounded の
方のインスタンスが自分の挙動をすべて自分で制御している所がおも
しろいかと思います。


class Iteration < Succession
  def initialize(first, condition, increment)
    super(first)
    @first, @condition, @increment = first, condition, increment
  end
  def inc; @obj = @increment.call(@obj); end
  def status; @condition.call(@obj); end
end

class Range3
  include Enumerable
  def initialize(first, condition, increment)
    @first, @condition, @increment = first, condition, increment
  end
  def each(&block)
    Iteration.new(@first, @condition, @increment).start(&block)
  end
end

# 例2
a = Range3.new(10, proc{|x| x < 12}, proc{|x| x + 0.5})
a.each { |x| p x } #=> 10, 10.5, 11.0, 11.5

こっちも Range2 と似た感じ。


Integer のインクリメントを実現するモデルを考えていて、こういうも
のが出て来たのですが。便利かどうかはちょっと分からないですね。

In This Thread