[#7878] libwww-ruby — TAKAHASHI Masayoshi <maki@...>

高橋です。ごぶさたしています。

31 messages 1998/05/13
[#7881] RE: libwww-ruby — OZAWA Sakuro <crouton@...> 1998/05/13

さく%札幌出張@塩尻です.

[#7882] Re: libwww-ruby — matz@... (Yukihiro Matsumoto) 1998/05/14

まつもと ゆきひろです

[#7884] Re: libwww-ruby — Eiji-usagi-MATSUmoto <ematsu@...> 1998/05/14

うさぎです

[#7885] Re: libwww-ruby — matz@... (Yukihiro Matsumoto) 1998/05/14

まつもと ゆきひろです

[#7886] Re: libwww-ruby — Eiji-usagi-MATSUmoto <ematsu@...> 1998/05/14

うさぎです

[#7888] Re: libwww-ruby — Mitsuru Ogino <ogino@...> 1998/05/14

ちょっとした疑問ですが。

[#7904] Re: filename (Re: libwww-ruby) — 助田 雅紀 <masaki.suketa@...>

助田です。

19 messages 1998/05/15
[#7908] Re: filename (Re: libwww-ruby) — ttate@... 1998/05/15

立石@JAISTです。

[#7909] Ruby Application Archive (Re: Re: filename (Re: libwww-ruby)) — matz@... (Yukihiro Matsumoto) 1998/05/15

まつもと ゆきひろです

[#7912] Re: filename (Re: libwww-ruby) — Makoto Nukui <gnue@...>

ども、GNUE(鵺)です。

16 messages 1998/05/15
[#7926] Re: filename (Re: libwww-ruby) — TAKAHASHI Masayoshi <maki@...> 1998/05/15

高橋です。

[#7965] links from ruby home page — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

28 messages 1998/05/18
[#7966] Re: links from ruby home page — WATANABE Tetsuya <tetsu@...> 1998/05/18

>>>>> "matz" == Yukihiro Matsumoto <matz@netlab.co.jp> writes:

[#7967] Re: links from ruby home page — matz@... (Yukihiro Matsumoto) 1998/05/18

まつもと ゆきひろです

[#7968] Re: links from ruby home page — WATANABE Tetsuya <tetsu@...> 1998/05/18

>>>>> "matz" == Yukihiro Matsumoto <matz@netlab.co.jp> writes:

[#7969] Re: links from ruby home page — matz@... (Yukihiro Matsumoto) 1998/05/18

まつもと ゆきひろです

[#7974] Re: links from ruby home page — matz@... (Yukihiro Matsumoto) 1998/05/18

まつもと ゆきひろです

[#7979] dbm — Kazuhiro HIWADA <hiwada@...> 1998/05/18

ひわだといいます。こんにちは。

[#7990] Re: dbm — matz@... (Yukihiro Matsumoto) 1998/05/19

まつもと ゆきひろです

[#8002] Dir.open order — Kikutani Makoto <kikutani@...>

きくたに@マサチューセッツです。

13 messages 1998/05/19

[#8099] cathedral v.s. bazaar — Kikutani Makoto <kikutani@...>

debian-usersで話題になってる

23 messages 1998/05/27
[#8103] Re: cathedral v.s. bazaar — TAKAHASHI Masayoshi <maki@...> 1998/05/28

高橋です。

[#8104] Re: cathedral v.s. bazaar — WATANABE Tetsuya <tetsu@...> 1998/05/28

>>>>> "T" == TAKAHASHI Masayoshi <maki@inac.co.jp> writes:

[#8106] Re: cathedral v.s. bazaar — ttate@... 1998/05/28

立石@JAISTです。

[ruby-list:8050] Re: ruby book (Re: Re: Dir.open order)

From: Inaba Hiroto <inaba@...>
Date: 1998-05-20 14:49:20 UTC
List: ruby-list #8050
From: matz@netlab.co.jp (Yukihiro Matsumoto)
Subject: [ruby-list:8029] ruby book (Re:  Re: Dir.open order)
Date: Wed, 20 May 1998 12:54:05 +0900

> In message "[ruby-list:8028] Re: Dir.open order"
>     on 98/05/20, Kikutani Makoto <kikutani@debian.or.jp> writes:
> 
> |> 慣れて下さい.これがRuby流です.
> |
> |こういうのがRuby本に満載ですね(^^)。
> 
> そうなると良いですねえ.まだTipsに関する章(6章)は書いてない
> ので,ナニが載るのかはっきりしたことは言えないのですが.

もしこの手法を載せるとした時の為に、ちょっと書きます。

えっと、本質的に同じ手法がperl5.004添付のドキュメントperlfaq4.podの
「How do I sort an array by (anything)?」に書かれてます。当然collectで
はなくてmapを使うんですが。

			:
       If you have a complicated function needed to pull out the
       part you want to sort on, then don't do it inside the sort
       function.  Pull it out first, because the sort BLOCK can
       be called many times for the same element.  Here's an
       example of how to pull out the first word after the first
       number on each item, and then sort those words case-
       insensitively.

           @idx = ();
           for (@data) {
               ($item) = /\d+\s*(\S+)/;
               push @idx, uc($item);
           }
           @sorted = @data[ sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx ];

       Which could also be written this way, using a trick that's
       come to be known as the Schwartzian Transform:

           @sorted = map  { $_->[0] }
                     sort { $a->[1] cmp $b->[1] }
                     map  { [ $_, uc((/\d+\s*(\S+)/ )[0] ] } @data;
			:

書かれているように、Perl communityではこの手法に Schwartzian Transform 
という名前がついていて、たまにcomp.lang.perl.miscでこういう話題の時に
使われてます。

--
			   稲葉 浩人 (inaba@st.rim.or.jp)

In This Thread

Prev Next