[#8257] Re: Smalltalk [Re: design patterns] — 助田 雅紀 <masaki.suketa@...>

助田です。

11 messages 1998/06/09
[#8259] Re: Smalltalk [Re: design patterns] — KIMURA Koichi <kkimura@...> 1998/06/10

[#8262] TkGrid do not exist? — Hiramatu Yoshifumi <hiramatu@...>

平松です。

26 messages 1998/06/10
[#8266] Re: TkGrid do not exist? — matz@... (Yukihiro Matsumoto) 1998/06/10

まつもと ゆきひろです

[#8269] Re: TkGrid do not exist? — NAGAI Hidetoshi <nagai@...> 1998/06/10

永井@知能.九工大です.

[#8271] Re: TkGrid do not exist? — NAGAI Hidetoshi <nagai@...> 1998/06/10

永井@知能.九工大です.

[#8375] new MethodIndex — keiju@... (Keiju ISHITSUKA)

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

21 messages 1998/06/16
[#8447] new MethodIndex — TEI meiki <tei@...> 1998/06/20

こんにちは、鄭です。

[#8448] new MethodIndex — TEI meiki <tei@...> 1998/06/20

再び、鄭です。_o_

[#8418] how to use delegate — gotoken@... (GOTO Kentaro)

ごとけんです

18 messages 1998/06/18
[#8419] Re: how to use delegate — matz@... (Yukihiro Matsumoto) 1998/06/19

まつもと ゆきひろです

[#8420] Re: how to use delegate — gotoken@... (GOTO Kentaro) 1998/06/19

ごとけんです

[#8421] Re: how to use delegate — matz@... (Yukihiro Matsumoto) 1998/06/19

まつもと ゆきひろです

[#8521] hash sort — "Kazuhiro Yoshida" <s95l980@...>

もりきゅうです。

34 messages 1998/06/26
[#8523] hash sort — gotoken@... (GOTO Kentaro) 1998/06/26

ごとけんです

[#8533] Re: hash sort — WATANABE Hirofumi <watanabe@...> 1998/06/26

わたなべです.

[#8534] Re: hash sort — gotoken@... (GOTO Kentaro) 1998/06/26

ごとけんです

[#8536] Re: hash sort — Sinichiro Dezawa <dezawa@...> 1998/06/26

出沢です

[#8538] Re: hash sort — gotoken@... (GOTO Kentaro) 1998/06/26

ごとけんです

[#8539] Re: hash sort — TAKAHASHI Masayoshi <maki@...> 1998/06/26

高橋です。

[#8541] Re: hash sort — gotoken@... (GOTO Kentaro) 1998/06/26

ごとけんです

[#8546] Re: hash sort — Tadayoshi Funaba <tadf@...> 1998/06/26

ふなばです。

[ruby-list:8486] cursor

From: "MAEDA Shugo" <shugo@...>
Date: 1998-06-23 14:09:03 UTC
List: ruby-list #8486
前田です。

以前少し話題にのぼった外部イテレータのライブラリを作ってみました。

使い方は、

require "cursor"

ary = [1, 2, 3]
i = ary.cursor
until i.done?
  p i.current
  i.next
end

といった感じです。

def pareach(*args)
  cursors = args.collect { |i| i.cursor }
  until cursors.find { |c| c.done? }
    yield(*cursors.collect { |c| c.current })
    cursors.each { |c| c.next }
  end
end

ary1 = [1, 2, 3]
ary2 = ["one", "two", "three"]

pareach(ary1, ary2) { |i1, i2|
  print i1, ":", i2, "\n"
}

などとすると並行eachが書けます。
# 並行eachといってもマルチスレッドではないです(^^;

Cで書いたのはスピードのためです。
でもやっぱり内部イテレータの方が楽だし速いですね。

ところで、until condよりwhile !condの方が速いのですね。
ちょっと意外でした。
--
前田 修吾

Attachments (2)

cursor.tar.gz (1.68 KB, Archive)
cursor.tar.gz (0 Bytes, application/x-be_attribute)

In This Thread

Prev Next