[#121980] SOT gmail invites — Lyndon Samson <lyndon.samson@...>

X % of the people of this list appear to be using GoogleMail, where X

93 messages 2004/12/01
[#122062] Re: SOT gmail invites — Steve Zich <szich@...> 2004/12/01

On 2004-11-30 19:26:08 -0800, Lyndon Samson <lyndon.samson@gmail.com> said:

[#122063] Re: SOT gmail invites — Robert McGovern <robert.mcgovern@...> 2004/12/01

On Thu, 2 Dec 2004 02:17:45 +0900, Steve Zich >

[#122065] Re: SOT gmail invites — tony summerfelt <snowzone5@...> 2004/12/01

i've got 3 left...

[#122066] Re: SOT gmail invites — Pat Eyler <pate@...> 2004/12/01

I'd take one,

[#122072] Re: SOT gmail invites — tony summerfelt <snowzone5@...> 2004/12/01

On Thu, 2 Dec 2004 02:58:33 +0900, you wrote:

[#122073] Re: SOT gmail invites — Mark Hubbart <discordantus@...> 2004/12/01

On Thu, 2 Dec 2004 03:57:19 +0900, tony summerfelt

[#122075] Re: SOT gmail invites — Matt Maycock <ummaycoc@...> 2004/12/01

I've got some, too...

[#122112] Re: SOT gmail invites — Lyndon Samson <lyndon.samson@...> 2004/12/02

Ok, who missed out, I've got a couple left.

[#122120] Re: SOT gmail invites — Jamis Buck <jamis_buck@...> 2004/12/02

Lyndon Samson wrote:

[#122240] Re: SOT gmail invites — Stefan Schmiedl <s@...> 2004/12/02

On Thu, 2 Dec 2004 12:34:29 +0900,

[#122246] Re: SOT gmail invites — Jamis Buck <jamis_buck@...> 2004/12/02

Stefan Schmiedl wrote:

[#122254] Re: SOT gmail invites — Carl Youngblood <carlwork@...> 2004/12/02

Jamis Buck wrote:

[#122397] Re: SOT gmail invites — Hans Fugal <hans@...> 2004/12/03

Carl Youngblood wrote:

[#122400] Re: SOT gmail invites — Carl Youngblood <carlwork@...> 2004/12/03

Hans Fugal wrote:

[#122427] Re: SOT gmail invites — Hans Fugal <hans@...> 2004/12/03

Carl Youngblood wrote:

[#122069] Rails with webrick slow as snails — Sarah Tanembaum <sarahtanembaum@...>

I've followed the sample installation

15 messages 2004/12/01
[#122071] Re: Rails with webrick slow as snails — David Heinemeier Hansson <david@...> 2004/12/01

> BUT

[#122083] Re: Rails with webrick slow as snails — Sarah Tanembaum <sarahtanembaum@...> 2004/12/01

David Heinemeier Hansson wrote:

[#122110] ordered hash ? — "itsme213" <itsme213@...>

Is there a pure-ruby ordered hash? I'm looking for something that will

44 messages 2004/12/02
[#122176] Re: ordered hash ? — Nikolai Weibull <mailing-lists.ruby-talk@...> 2004/12/02

* itsme213 <itsme213@hotmail.com> [Dec 02, 2004 14:00]:

[#122156] Does anyone have benchmark programs for YARV? — SASADA Koichi <ko1@...>

Hi,

18 messages 2004/12/02

[#122177] nested defs, what if... — Hugh Sasse Staff Elec Eng <hgs@...>

This is too half-baked to be an RCR, but here goes...

17 messages 2004/12/02
[#122179] Re: nested defs, what if... — Austin Ziegler <halostatue@...> 2004/12/02

On Thu, 2 Dec 2004 23:44:08 +0900, Hugh Sasse Staff Elec Eng

[#122212] Re: nested defs, what if... — Brian =?ISO-8859-15?Q?Schr=F6der?= <ruby@...> 2004/12/02

On Thu, 2 Dec 2004 23:57:09 +0900

[#122180] Net::SSH 0.6.0 — Jamis Buck <jamis_buck@...>

Here's another release of Net::SSH, your friendly neighborhood pure-Ruby

12 messages 2004/12/02

[#122288] Ruby documentation. — Adam Fabian <afabian@...>

I'm kind of getting the impression that Ruby might not be

31 messages 2004/12/03

[#122350] Crosswords (#10) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

18 messages 2004/12/03

[#122371] GC run at end of script execution - order in which objects are claimed? — Tilman Sauerbeck <tilman@...>

Hi,

13 messages 2004/12/03

[#122416] *sigh* Anyone having wireless working on a linux machine? — "Abraham Vionas" <abe_ml@...>

I've tried something like eight different distributions and the best I've

11 messages 2004/12/03

[#122444] Using yield — "Joe Van Dyk" <joe.vandyk@...>

I come from a heavy C++ background, discovered Ruby a few months ago and

26 messages 2004/12/04

[#122475] Ruby 2.0 — "Joe Van Dyk" <joe.vandyk@...>

When is Ruby 2.0 due? Or estimated due date?

44 messages 2004/12/04
[#122544] Re: Ruby 2.0 — w_a_x_man@... (William James) 2004/12/04

Brian Mitchell <binary42@gmail.com> wrote

[#122549] Re: Ruby 2.0 — Florian Gross <flgr@...> 2004/12/04

William James wrote:

[#122554] Re: Ruby 2.0 — Giovanni Intini <intinig@...> 2004/12/04

> 32.times{|y|print" "*(31-y),(0..y).map{|x|~y&x>0?" .":" A"},$/}

[#122604] Re: Ruby 2.0 — Florian Gross <flgr@...> 2004/12/05

Giovanni Intini wrote:

[#122619] patch to "make def return something useful" — Peter <Peter.Vanbroekhoven@...>

In RCR 277 it is proposed to have def return something useful, more

15 messages 2004/12/06

[#122630] Freezing Variable Assignment — Nicholas Van Weerdenburg <vanweerd@...>

Hi,

62 messages 2004/12/06
[#122740] Re: Freezing Variable Assignment — "itsme213" <itsme213@...> 2004/12/06

[#122762] Re: Freezing Variable Assignment — "itsme213" <itsme213@...> 2004/12/07

[#122766] Re: Freezing Variable Assignment — Austin Ziegler <halostatue@...> 2004/12/07

On Tue, 7 Dec 2004 12:07:32 +0900, itsme213 <itsme213@hotmail.com>

[#122805] Re: Freezing Variable Assignment — Nicholas Van Weerdenburg <vanweerd@...> 2004/12/07

On Tue, 7 Dec 2004 13:44:09 +0900, Austin Ziegler <halostatue@gmail.com> wrote:

[#122644] Signatures and one liners — Brian Mitchell <binary42@...>

readers.each{|x| puts "Hi #{x},"}

23 messages 2004/12/06

[#122645] Duck images — "Dave Burt" <dave@...>

Hi,

35 messages 2004/12/06
[#122697] Re: Duck images — ptkwt@... (Phil Tomson) 2004/12/06

In article <vcSsd.61264$K7.35690@news-server.bigpond.net.au>,

[#122713] Re: Duck images — "trans. (T. Onoma)" <transami@...> 2004/12/06

On Monday 06 December 2004 12:52 pm, Phil Tomson wrote:

[#122715] Re: Duck images — Michael DeHaan <michael.dehaan@...> 2004/12/06

0>

[#122696] Ruby Article at Linux Journal — pat eyler <pat.eyler@...>

Hey, it looks like our own Ara Howard has been busy. He's got a cool

15 messages 2004/12/06

[#122775] Recommened readings? — "John" <jtrunek@...>

For one of my university courses, I have to complete a paper on Ruby.

13 messages 2004/12/07

[#122782] Ruby Weekly News 29th Nov - 5th Dec 2004 — timsuth@... (Tim Sutherland)

http://www.rubygarden.org/ruby?RubyNews/2004-11-29

12 messages 2004/12/07

[#122798] Idiom for creating hash from two arrays — Jonathan Paisley <jp-www@...>

Hello all,

22 messages 2004/12/07

[#122875] Re: [rcr] String#split behaves odd — "Pe, Botp" <botp@...>

Ryan Davis [mailto:ryand-ruby@zenspider.com] wrote:

30 messages 2004/12/08
[#122886] Re: [rcr] String#split behaves odd — Yukihiro Matsumoto <matz@...> 2004/12/08

Hi,

[#122894] Re: [rcr] String#split behaves odd — "trans. (T. Onoma)" <transami@...> 2004/12/08

On Wednesday 08 December 2004 12:00 am, Yukihiro Matsumoto wrote:

[#122940] Re: [rcr] String#split behaves odd — Florian Frank <flori@...> 2004/12/08

On 2004-12-08 15:56:01 +0900, trans. (T. Onoma) wrote:

[#123046] Re: [rcr] String#split behaves odd — "trans. (T. Onoma)" <transami@...> 2004/12/09

On Wednesday 08 December 2004 10:00 am, Florian Frank wrote:

[#123068] Re: [rcr] String#split behaves odd — Glenn Parker <glenn.parker@...> 2004/12/09

trans. (T. Onoma) wrote:

[#123085] Re: [rcr] String#split behaves odd — "trans. (T. Onoma)" <transami@...> 2004/12/09

On Thursday 09 December 2004 08:19 am, Glenn Parker wrote:

[#123100] Re: String#split behaves odd — Ibraheem Umaru-Mohammed <iumarumohammed@...> 2004/12/09

++ trans. (T. Onoma) [ruby-talk] [10/12/04 00:43 +0900]:

[#123103] Re: String#split behaves odd — "trans. (T. Onoma)" <transami@...> 2004/12/09

On Thursday 09 December 2004 12:29 pm, Ibraheem Umaru-Mohammed wrote:

[#122918] RubyScript2Exe 0.2.0 — "Erik Veenstra" <pan@...>

28 messages 2004/12/08

[#123076] Crosswords (#10) — Ruby Quiz <james@...>

The summary for this week's quiz should be:

11 messages 2004/12/09

[#123137] Want to Write a Book? — Dave Thomas <dave@...>

Gentle Ruby folk:

40 messages 2004/12/10

[#123189] Learning Tic-Tac-Toe (#11) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

58 messages 2004/12/10
[#123196] Re: [QUIZ] Learning Tic-Tac-Toe (#11) — Brian =?ISO-8859-15?Q?Schr=F6der?= <ruby@...> 2004/12/10

On Fri, 10 Dec 2004 23:29:02 +0900

[#123198] Re: [QUIZ] Learning Tic-Tac-Toe (#11) — James Edward Gray II <james@...> 2004/12/10

On Dec 10, 2004, at 9:19 AM, Brian Schrer wrote:

[#123204] Re: [QUIZ] Learning Tic-Tac-Toe (#11) — Brian =?ISO-8859-15?Q?Schr=F6der?= <ruby@...> 2004/12/10

On Sat, 11 Dec 2004 00:42:04 +0900

[#123206] Re: [QUIZ] Learning Tic-Tac-Toe (#11) — James Edward Gray II <james@...> 2004/12/10

On Dec 10, 2004, at 10:11 AM, Brian Schrer wrote:

[#123218] Re: [QUIZ] Learning Tic-Tac-Toe (#11) — Brian =?ISO-8859-15?Q?Schr=F6der?= <ruby@...> 2004/12/10

On Sat, 11 Dec 2004 01:22:30 +0900

[#123313] Re: [QUIZ] Learning Tic-Tac-Toe (#11) — Hans Fugal <fugalh@...> 2004/12/11

It would be good to be able to play against eachother when this is all

[#123195] iconv replacement for windows? — Thomas Leitner <t_leitner@...>

Hi,

17 messages 2004/12/10
[#123205] Re: iconv replacement for windows? — Thomas Leitner <t_leitner@...> 2004/12/10

On Sat, 11 Dec 2004 00:45:11 +0900

[#123222] How to make a deep copy of an object (Searching for Idiom) — Brian =?ISO-8859-15?Q?Schr=F6der?= <ruby@...>

Hello Group,

18 messages 2004/12/10

[#123317] puts / print as method not keyword? — zuzu <sean.zuzu@...>

so, i'm thinking about language design with a particular interest in

23 messages 2004/12/11
[#123319] Re: puts / print as method not keyword? — Ilmari Heikkinen <kig@...> 2004/12/11

[#123321] Re: puts / print as method not keyword? — zuzu <sean.zuzu@...> 2004/12/11

On Sun, 12 Dec 2004 05:23:10 +0900, Ilmari Heikkinen <kig@misfiring.net> wrote:

[#123351] Find every location of "th" in string. — "William James" <w_a_x_man@...>

Find location of every "th" in "the thin man thinks".

14 messages 2004/12/12

[#123426] Any bug/issue trackers written in Ruby? — "J. D." <jd@...>

Hi,

12 messages 2004/12/12

[#123454] Abstracts and Interfaces in Ruby? — Miles Keaton <mileskeaton@...>

What's the recommended Ruby way to do abstract classes and abstract methods?

12 messages 2004/12/13

[#123590] wxRuby and other GUI toolkits — Nick <devel@...>

24 messages 2004/12/14
[#123616] Re: wxRuby and other GUI toolkits — "itsme213" <itsme213@...> 2004/12/14

Any chance you could provide a simplified interface along the lines

[#123614] Apache2, FastCGI and Rails on Windows — "Williams, Chris" <Chris.Williams@...>

I've been running around in circles trying to enable FastCGI on my rails

20 messages 2004/12/14
[#123630] Re: Apache2, FastCGI and Rails on Windows — Kent Sibilev <ksibilev@...> 2004/12/14

I'm running my rails application on the same environment and it works

[#123825] Re: Apache2, FastCGI and Rails on Windows — Sarah Tanembaum <sarahtanembaum@...> 2004/12/16

Kent Sibilev wrote:

[#123831] Re: Apache2, FastCGI and Rails on Windows — Kent Sibilev <ksibilev@...> 2004/12/16

Oh, This is quite easy. I assume you have Ruby and RubyForApache

[#123626] Ruby Wiki engine w/ability to upload files — Bil Kleb <Bil.Kleb@...>

Hello again,

12 messages 2004/12/14

[#123661] rand.rb 0.9: Random access methods for Enumerables — Ilmari Heikkinen <kig@...>

Hello all, here's a little convenience library we whipped up a couple

17 messages 2004/12/15

[#123694] Re: [BUG] unknown node type 0 - SERIOUS ENOUGH TO MIGRATE AWAY FROM RUBY? — Andrew Walrond <andrew@...>

This is a long standing bug in Ruby, and has been reported hundreds of times

16 messages 2004/12/15

[#123740] P2P application in 15 lines of Python posted on slashdot — slonik AZ <slonik.az@...>

Hi Everybody,

16 messages 2004/12/15

[#123815] Ruby Cocoa (OS X) questions: deployment & interface builder — Michael DeHaan <michael.dehaan@...>

Folks,

13 messages 2004/12/16

[#123852] Rails 0.9: Fast development, breakpoints, validations... — David Heinemeier Hansson <david@...>

Another huge upgrade with again close to 100 changes, additions, and

10 messages 2004/12/16

[#123898] Scrabble Stems (#12) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

22 messages 2004/12/17

[#123983] OT: vi useability question — Lothar Scholz <mailinglists@...>

Hello ruby-talk,

30 messages 2004/12/18
[#124013] Re: OT: vi useability question — Roeland Moors <roelandmoors@...> 2004/12/19

On Sun, Dec 19, 2004 at 08:07:28AM +0900, Lothar Scholz wrote:

[#124130] Re: OT: vi useability question — Hans Fugal <fugalh@...> 2004/12/20

Roeland Moors wrote:

[#124131] A RDoc template without frames — David Heinemeier Hansson <david@...>

Despite the snazzy look of the new default RDoc templates with three

21 messages 2004/12/20
[#124171] Re: A RDoc template without frames — "John W. Long" <ng@...> 2004/12/21

I did a design up once for something without frames:

[#124176] Re: A RDoc template without frames — why the lucky stiff <ruby-talk@...> 2004/12/21

John W. Long wrote:

[#124140] Is there any ruby compatible graphics/imaging utilities ... — Sarah Tanembaum <sarahtanembaum@...>

that works under native mswin323232 or at least with Cygwin X windows

16 messages 2004/12/20

[#124175] Text::Hyphen 1.0.0 — Austin Ziegler <halostatue@...>

I just told you that I'm releasing Text::Hyphen 1.0.0, and here it is

14 messages 2004/12/21

[#124182] curses - how to use unicode — Simon Strandgaard <neoneye@...>

Yesterday I got xterm working with UTF-8. I had made an oneliner that

13 messages 2004/12/21

[#124198] Re: OT: vi useability question — "Pe, Botp" <botp@...>

Mikael Brockman [mailto:mikael@phubuh.org] wrote:

28 messages 2004/12/21
[#124200] Re: OT: vi useability question — Dick Davies <rasputnik@...> 2004/12/21

* "Pe?a, Botp" <botp@delmonte-phil.com> [1210 11:10]:

[#124290] Re: OT: vi useability question — Fredrik Jagenheim <jagenheim@...> 2004/12/22

On Tue, 21 Dec 2004 20:16:14 +0900, Dick Davies

[#124329] All I want to do is move a directory :( — "trans. (T. Onoma)" <transami@...>

Very frustrated. I have just spent well over an hour trying to do the simplest

16 messages 2004/12/22
[#124339] Re: All I want to do is move a directory :( — Gennady Bystritksy <gfb@...> 2004/12/22

trans. (T. Onoma) wrote:

[#124343] Re: All I want to do is move a directory :( — "trans. (T. Onoma)" <transami@...> 2004/12/22

On Wednesday 22 December 2004 04:25 pm, Gennady Bystritksy wrote:

[#124344] Re: All I want to do is move a directory :( — "trans. (T. Onoma)" <transami@...> 2004/12/23

I think the problem may be that the :force option isn't working correctly on

[#124391] Merry Christmas — Christian Neukirchen <chneukirchen@...>

20 messages 2004/12/24
[#124397] Re: Merry Christmas — "trans. (T. Onoma)" <transami@...> 2004/12/24

:( I get

[#124400] Re: Merry Christmas — CT <demerzel@...> 2004/12/24

> On Friday 24 December 2004 08:21 am, Christian Neukirchen wrote:

[#124433] Re: Merry Christmas — Michael Neumann <mneumann@...> 2004/12/25

CT wrote:

[#124413] ruby 1.8.2 — Yukihiro Matsumoto <matz@...>

Merry Christmas,

25 messages 2004/12/25

[#124439] HTML and CSS validation — Bil Kleb <Bil.Kleb@...>

What's the best method to automate the validation

17 messages 2004/12/25

[#124502] Ri bug in new 1.8.2 release — jim@...

Hi

13 messages 2004/12/26

[#124562] split on '' (and another for split -1) — "trans. (T. Onoma)" <transami@...>

Here's a generic routine I'm working on:

11 messages 2004/12/27

[#124591] Ruby Philosophy — Darren Crotchett <rubylang@...>

I'm trying to get a feel for the philosophical differences between Smalltalk,

19 messages 2004/12/28

[#124596] Best ways to accelerate Ruby's popularity — Thursday <nospam@...>

I think Ruby's popularity is growing, but I can't help but wonder what

196 messages 2004/12/28
[#127081] Re: Best ways to accelerate Ruby's popularity — Ben Giddings <bg-rubytalk@...> 2005/01/19

Hi all, I got to this discussion really late, but I have some ideas.

[#127100] Re: Best ways to accelerate Ruby's popularity — Joel VanderWerf <vjoel@...> 2005/01/19

Ben Giddings wrote:

[#127162] Re: Best ways to accelerate Ruby's popularity — Ben Giddings <bg-rubytalk@...> 2005/01/19

Joel VanderWerf wrote:

[#127180] Re: Best ways to accelerate Ruby's popularity — Yukihiro Matsumoto <matz@...> 2005/01/19

Hi,

[#127191] Re: Best ways to accelerate Ruby's popularity — Ben Giddings <bg-rubytalk@...> 2005/01/19

Yukihiro Matsumoto wrote:

[#127207] Re: Best ways to accelerate Ruby's popularity — ruby talk <ruby.talk.list@...> 2005/01/19

On Thu, 20 Jan 2005 03:14:28 +0900, Ben Giddings

[#127228] Re: Best ways to accelerate Ruby's popularity — Ben Giddings <bg-rubytalk@...> 2005/01/19

ruby talk (AKA James Britt) wrote:

[#127232] Re: Best ways to accelerate Ruby's popularity — why the lucky stiff <ruby-talk@...> 2005/01/19

Ben Giddings (bg-rubytalk@infofiend.com) wrote:

[#127255] Re: Best ways to accelerate Ruby's popularity — gabriele renzi <rff_rff@...> 2005/01/19

why the lucky stiff ha scritto:

[#127315] Re: Best ways to accelerate Ruby's popularity — "zimba.tm@..." <zimba.tm@...> 2005/01/20

I think it's cool to have community-driven websites,

[#127353] Re: Best ways to accelerate Ruby's popularity — Ben Giddings <bg-rubytalk@...> 2005/01/20

zimba.tm@gmail.com wrote:

[#127360] Re: Best ways to accelerate Ruby's popularity — "David A. Black" <dblack@...> 2005/01/20

HI --

[#127369] Re: Best ways to accelerate Ruby's popularity — Ben Giddings <bg-rubytalk@...> 2005/01/20

David A. Black wrote:

[#127674] Re: Best ways to accelerate Ruby's popularity — "David A. Black" <dblack@...> 2005/01/22

Hi --

[#127984] Re: Best ways to accelerate Ruby's popularity — Ben Giddings <bg-rubytalk@...> 2005/01/25

David A. Black wrote:

[#128748] Re: Best ways to accelerate Ruby's popularity — Ian Hobson <Ian.Hobson@...> 2005/01/28

In message <41F58CEF.70807@infofiend.com>, Ben Giddings

[#127424] Re: Best ways to accelerate Ruby's popularity — James Britt <jamesUNDERBARb@...> 2005/01/20

David A. Black wrote:

[#127431] Re: Best ways to accelerate Ruby's popularity — "Curt Hibbs" <curt@...> 2005/01/20

James Britt wrote:

[#127435] Re: Best ways to accelerate Ruby's popularity — James Britt <jamesUNDERBARb@...> 2005/01/21

Curt Hibbs wrote:

[#124652] Re: Best ways to accelerate Ruby's popularity — gabriele renzi <rff_rff@...> 2004/12/28

Thursday ha scritto:

[#124672] Re: Best ways to accelerate Ruby's popularity — Tom Copeland <tom@...> 2004/12/28

On Tue, 2004-12-28 at 11:36, gabriele renzi wrote:

[#124674] Re: Best ways to accelerate Ruby's popularity — Premshree Pillai <premshree.pillai@...> 2004/12/28

On Wed, 29 Dec 2004 05:54:01 +0900, Tom Copeland <tom@infoether.com> wrote:

[#124675] Re: Best ways to accelerate Ruby's popularity — Tom Copeland <tom@...> 2004/12/28

On Tue, 2004-12-28 at 16:00, Premshree Pillai wrote:

[#125257] Re: Best ways to accelerate Ruby's popularity — timsuth@... (Tim Sutherland) 2005/01/06

In article <41D44401.4060104@mktec.com>, Zach Dennis wrote:

[#124607] help on making ruby code faster — David Garamond <lists@...6.isreserved.com>

I use 128bit GUID values a lot, and on my Guid class there's the

17 messages 2004/12/28

[#124612] verifying a network connection — Thomas Metz <metz@...>

Hi,

13 messages 2004/12/28

[#124746] #send and private methods — Brian Palmer <brian@...>

I apologize if this has been discussed before and I missed it...

12 messages 2004/12/29

[#124805] Inheritance of class variables — "Eustaquio Rangel de Oliveira Jr." <eustaquiorangel@...>

Hello there.

18 messages 2004/12/30

[#124899] Ruby and Smalltalk like environment?

Hi there,

14 messages 2004/12/31

Re: puts / print as method not keyword?

From: zuzu <sean.zuzu@...>
Date: 2004-12-11 22:20:49 UTC
List: ruby-talk #123343
here is how jim was thinking of it.  he seems to love mixing in
Enumerable for all kinds of fun dataflow tricks, and that seemed not
such a bad idea to me.

but don't let this stifle your creativity thinking about postfix /
concatenative combinators this time around.  (the terminology of
"concatenative combinators" first found me by way of the Forth
language, which then influenced the Toy language.  feel free to also
browse jim cunningham's excellent programming language wiki at
c2.com).

From: Jim Weirich <jim@weirichhouse.org>
Reply-To: ruby-talk@ruby-lang.org
To: ruby-talk ML <ruby-talk@ruby-lang.org>
Date: Fri, 27 Aug 2004 11:07:09 +0900
Subject: Re: python generators to ruby closures, help

William Morgan wrote:
> Yes. I don't think you want the Generator class at all then. As the
> email you quoted said, Python generators are a solution to a problem
> that Ruby doesn't have. Generators have a place in Ruby but this ain't
> it.
>
> From what I can tell, all the functionality they build up in the Python
> example is just so that they can do thing that in Ruby can be done
> neatly with iterators, like this:

As William pointed out, enumerator pipes can be implemented in Ruby
without resorting to continuations, and that the current enumerator
syntax is very pipe-like in many ways.

However, one thing the Python version handles that enumerator chaining
does not is an infinite enumerator.  In the python examples, we have
the following construct:

   Ints() | firstTen | oddNotDivBy3

Ints() is a generator that will generate all the integers (given
enough time and space).  The next filter "firstTen" only takes the
first 10 of those numbers.  Since the generator chain only takes a
number from a generator when it is needed, the Ints() generator is
never asked for any more than 10 number.

We can do the same with Ruby enumerators.  Imagine a OddNumberFilter
object that implements a each method like this ...

  class OddNumberFilter
    include Enumerable
    attr_accessor :source
    def each
      @source.each { |n| yield(n) if (n % 2) != 0 }
    end
  end

It uses a source enumerable to generate numbers and only yields when
it finds an odd number.  We can use it like this ...

   odds_only = OddNumberFilter.new
   odds_only.source = (1..10)
   odds_only.to_a              # => [1, 3, 5, 7, 9]

Since a filter can take _any_ enumerable as a source, it can even take
other filters.  Let's generalize our OddNumberFilter class to a
CondFilter class that takes a condition and only passes items that
pass the condition.

  class CondFilter
    include Enumerable
    attr_accessor :source
    def initialize(&block)
      @block = block
    end
    def each
      @source.each { |it| yield(it) if @block.call(it) }
    end
  end

Now we create a chain of filters ...

  odds_only = CondFilter.new { |n| (n % 2) != 0 }
  odds_only.source = (1..10)

  divisible_by_three = CondFilter.new { |n| (n % 3) == 0 }
  divisible_by_three.source = odds_only

  divisible_by_three.to_a    #=> [3, 9]

It works, but it is ugly.  So lets create a little syntactic sugar to
get this to work ...

  module Enumerable
    def |(filter)
      filter.source = self
      filter
    end
  end

  odds_only = CondFilter.new { |n| (n%2) != 0 }
  divisible_by_three = CondFilter.new { |n| (n%3) == 0 }

  pipe = (1..10) | odds_only | divisible_by_three
  pipe.to_a       # => [3, 9]

With this foundation, handling infinite enumerations are easy ...

  class Ints
    include Enumerable
    def initialize
      @n = 0
    end
    def each
      loop do
        yield @n
        @n += 1
      end
    end
  end

And a class to take only so many items ...

  class Take
    include Enumerable
    attr_accessor :source

    def initialize(limit)
      @limit = limit
    end
    def each
      n = 0
      @source.each do |it|
        n += 1
        break if n > @limit
        yield it
      end
    end
  end

  ( Ints.new | Take.new(5) ).to_a      # => [0, 1, 2, 3, 4]

From this point the File generator and the other stuff in the Python
example should be obvious.

Here's a fun puzzle.  Using filters, create a Sieve of Erasothanes
filter that, given an input of Ints.new, will generate a series of
prime numbers.  In other words, the code ...

  ( Ints.new | Primes.new | Take.new(100) ).to_a

will create an array of the first 100 prime numbers.

I've attached full examples and test suites for all the the above
(although factored a bit differently), so don't peek if you want to work
out the Primes puzzle ...

--
-- Jim Weirich    jim@weirichhouse.org     http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

#!/usr/bin/env ruby

require 'find'

module Enumerable
 def |(filter)
   filter.source = self
   filter
 end
end

class EmptyEnumClass
 include Enumerable
 def each() end
end

EmptyEnum = EmptyEnumClass.new

class EnumFilter
 include Enumerable
 attr_reader :source
 def initialize(source=nil)
   @source = source || EmptyEnum
 end
 def source=(new_source)
   case @source
   when EnumFilter
     @source.source = new_source
   else
     @source = new_source
   end
 end
 def each(&block)
   @source.each(block)
 end
end

class CondFilter < EnumFilter
 def initialize(&block)
   super()
   @block = block
 end
 def each
   @source.each do |it| yield it if @block[it] end
 end
end

class Ints
 include Enumerable
 def initialize
   @n = 0
 end
 def each
   loop do
     yield @n
     @n += 1
   end
 end
end

class Quit < EnumFilter
 def initialize(&block)
   @block = block
 end
 def each
   @source.each do |it|
     break if @block[it]
     yield it
   end
 end
end

class Start < EnumFilter
 def initialize(start)
   @start = start
 end
 def each
   @source.each do |it|
     yield it if it >= @start
   end
 end
end

class Take < EnumFilter
 def initialize(limit)
   @limit = limit
 end
 def each
   n = 0
   @source.each do |it|
     break if n >= @limit
     yield it
     n += 1
   end
 end
end

class EnumFiles
 include Enumerable
 def initialize(fn)
   @file_name = fn
 end
 def each
   Find.find(@file_name) do |fn| yield fn end
 end
end

class Primes < EnumFilter
 def initialize
   super
   @source = Start.new(2)
 end
 def each
   loop do
     n = (@source | Take.new(1)).to_a[0]
     yield n
     @source = @source | new_filter(n)
   end
 end
 def new_filter(n)
   CondFilter.new { |it| (it%n) != 0 }
 end
end

#!/usr/bin/env ruby

require 'test/unit'
require 'enumpipe'

class TestEnumPipe < Test::Unit::TestCase

 def test_create
   ep = CondFilter.new
   assert ep
 end

 def test_odd
   odd_filter = CondFilter.new { |it| (it % 2) != 0 }
   odd_filter.source = (1..10)
   assert_equal [1,3,5,7,9], odd_filter.to_a
 end

 def test_no_source
   odd_filter = CondFilter.new { |it| (it % 2) != 0 }
   assert_equal [], odd_filter.to_a
 end

 def test_two_filters
   odd_filter = CondFilter.new { |it| (it % 2) != 0 }
   filter_thirds = CondFilter.new { |it| (it % 3) == 0 }
   odd_filter.source = (1..10)
   filter_thirds.source = odd_filter
   assert_equal [3, 9], filter_thirds.to_a
 end

 def test_left_pipeing
   odd_filter = CondFilter.new { |it| (it % 2) != 0 }
   filter_thirds = CondFilter.new { |it| (it % 3) == 0 }
   filter_thirds.source = odd_filter
   filter_thirds.source = (1..10)
   assert_equal [3, 9], filter_thirds.to_a
 end

 def test_pipe_syntax
   pipe = (1..10) | CondFilter.new { |it| (it%2) != 0 }
   assert_equal [1,3,5,7,9], pipe.to_a
 end

 def test_pipe_three
   src = (1..10)
   odd = CondFilter.new { |it| (it%2) != 0 }
   thirds = CondFilter.new { |it| (it%3) == 0 }
   pipe = src | odd | thirds
   assert_equal [3, 9], pipe.to_a
 end

 def test_pipe_right_associative
   src = (1..10)
   odd = CondFilter.new { |it| (it%2) != 0 }
   thirds = CondFilter.new { |it| (it%3) == 0 }
   pipe = src | (odd | thirds)
   assert_equal [3, 9], pipe.to_a
 end

 def test_infinite_takes
   pipe = Ints.new | Take.new(10)
   assert_equal (0...10).to_a, pipe.to_a
 end

 def test_multiple_takes_on_ints
   pipe = Ints.new | Take.new(2)
   assert_equal [0,1], pipe.to_a
   assert_equal [2,3], pipe.to_a
   assert_equal [4,5], pipe.to_a
 end

 def test_quit_filter
   pipe = Ints.new | Quit.new { |it| it > 5 }
   assert_equal [0,1,2,3,4,5], pipe.to_a
 end

 def test_start
   pipe = Ints.new | Start.new(5) | Take.new(3)
   assert_equal [5,6,7], pipe.to_a
 end

 def test_files
   files = EnumFiles.new(".")
   filelist = files.to_a
   assert filelist.member?("./enumpipe.rb")
   assert filelist.member?("./testenumpipe.rb")
 end

 def test_file_filter
   testfiles = EnumFiles.new('.') | CondFilter.new { |fn|
File.basename(fn) =~ /^test.*\.rb$/ }
   filelist = testfiles.to_a
   assert filelist.member?("./testenumpipe.rb")
 end

 def test_primes
   primes = Ints.new | Primes.new | Take.new(10)
   assert_equal [2,3,5,7,11,13,17,19,23,29], primes.to_a
 end

end


On Sat, 11 Dec 2004 17:06:13 -0500, zuzu <sean.zuzu@gmail.com> wrote:
> On Sun, 12 Dec 2004 06:23:06 +0900, Ilmari Heikkinen <kig@misfiring.net> wrote:
> > la, 2004-12-11 kello 22:38, zuzu kirjoitti:
> >
> > > perhaps i don't just want the
> > > default STDOUT but would like to specify tty3 versus tty9 or perhaps
> > > window7 of some screen tty multiplexing session or how emacs manages
> > > buffers, and so on...
> >
> > You would then replace STDOUT with e.g. STDERR, or even
> > File.open("log","a"){|f| f.puts(string) }
> 
> i wouldn't want to save to a file as an intermediary, and then have to
> use something like the 'tail' command in another tty...  (for example,
> imagine if you were writing a cryptography tool).   but since in unix
> "everything is a file", i suppose some way could exist to write to a
> tty "file" directly.
> 
> though what i am really imagining is something such as a window
> manager written in ruby, where the display windows are objects
> (instances of a Window class or whatever), and take advantage of
> "everything is an object" rather than "everything is a file".  like
> naked object or the self language, i would like then for window
> objects to say how to display themselves to the screen object.
> 
> 
> 
> > > oh, also, correct me if i'm wrong, but method/function argument
> > > passing really should only be used for CONSTRAINTS _not_ DATA.
> >
> > > and so i also feel that
> > >
> > >    string.puts(STDOUT)
> > >
> > > or i'm probably thinking more like
> > >
> > >    string.puts {STDOUT}
> > >
> > > much more closely follows the so-called "Principle of Least Surprise".
> >
> > string.puts(STDOUT) creates a coupling, the string must call a method of the
> > given object with itself as the argument. It must know that the object it's
> > passed responds to #puts.
> 
> i think to me this seems natural for the pure-OO "everything is an
> object" nature of ruby (or  smalltalk).  strings know how to display
> themselves, they just need to know where.  again, i think "naked
> objects" is the latest way to talk about this, though i often think of
> self language which was built on smalltalk.
> 
> > Also, string.puts(STDOUT) modifies its argument
> > (by printing a new line), which, to me at least, is a big no-no.
> 
> i agree that the appending of a newline feels like a no-no.
> 
> > STDOUT.puts(string) modifies only STDOUT. It doesn't (shouldn't) magically add
> > an extra line to the string. And maybe it's better to have all objects respond
> > to just #to_s instead of #puts, #print and #write.
> >
> > The postfix notation is tempting though, hmm..
> > If you look at unix pipes, they use a syntax like:
> >
> > method | method | method , last method taking care of doing things
> 
> yes!  yes!  yes!   again, referring to those old emails i had here on
> the list with jim weirich, the streams/dataflow/coroutines approach of
> pipes and filters (commonly experienced in unix) was my inspiration.
> but this chaining is not at all foreign to ruby, as quite often data
> "collects and selects" are performed with method chaining.  e.g.
> 
> Object.methods.sort
> 
> 
> 
> > The difference to Ruby's method.method.method is that the shell pipes aren't
> > namespaced to the preceding object. Ie. With shell pipes it'd be quite doable
> > to except the following to work in every situation:
> >
> > gets | reverse | puts , because they are in the global namespace. What you pass
> > through the pipe doesn't change the available methods.
> >
> > In ruby
> >
> > gets.reverse.puts
> > creates a dependency chain.
> >
> > gets must return something that responds to reverse, and reverse must return
> > something that responds to puts. Which is bad.
> 
> hmmm... is this any different than unix which works blindly in bytestreams?
> 
> 
> 
> > So maybe we should emulate
> > shell pipes in some other way?
> >
> > def in; yield self; end
> >
> > string.in{|s| STDOUT.puts(s)}
> >
> > Works in dataflow-style, too:
> >
> > string.in{|s| puts s; s}.reverse.in{|s| puts s}
> >
> > Keeps concerns to the objects whom they may concern (String
> > doesn't have to know about what methods IO has, etc.), and doesn't do
> > black-box modifications to its arguments.
> >
> > Comments?
> 
> hehe, now i have to dig up those old emails for myself and really put
> my brain to work on this.
> 
> thanks!!!
> -z
>

In This Thread