[#267026] attr_reader — 7stud 7stud <dolgun@...>

On p. 30-31 of "Programming Ruby (2nd ed)", there is this example:

15 messages 2007/09/01

[#267065] Seeing the source — Michel Cabili <michel.cabili@...>

Hello. I'm new to Ruby (and also to scripting languages).

38 messages 2007/09/01

[#267086] Help with leap year programing — HB <hbqian@...>

Hi, All,

19 messages 2007/09/01

[#267106] Singleton Modules rather than Singleton Classes — Trans <transfire@...>

This recently came up in the thread entitled "Python-style

14 messages 2007/09/01

[#267113] Parsing query parameters from hyperlink — "lrlebron@..." <lrlebron@...>

I am trying to parse strings like this

11 messages 2007/09/01
[#267128] Re: Parsing query parameters from hyperlink — Robert Klemme <shortcutter@...> 2007/09/01

On 01.09.2007 19:34, lrlebron@gmail.com wrote:

[#267184] How does ruby handle overloading? — pongba <pongba@...>

Matz once replied on Cedric's blog that

13 messages 2007/09/02

[#267261] subject line — "Devi Web Development" <devi.webmaster@...>

I don't know who would make this sort of decision, but could we put

103 messages 2007/09/02
[#267397] Re: subject line — Trans <transfire@...> 2007/09/03

[#267633] Re: subject line — Chad Perrin <perrin@...> 2007/09/04

On Tue, Sep 04, 2007 at 04:01:56AM +0900, Trans wrote:

[#267655] Re: subject line — Trans <transfire@...> 2007/09/04

[#267656] Re: subject line — Chad Perrin <perrin@...> 2007/09/04

On Wed, Sep 05, 2007 at 08:54:22AM +0900, Trans wrote:

[#267665] Re: subject line — "Rimantas Liubertas" <rimantas@...> 2007/09/05

> Any time you tell someone to completely change the tools (s)he uses,

[#267744] Re: subject line — Chad Perrin <perrin@...> 2007/09/05

On Wed, Sep 05, 2007 at 10:12:53AM +0900, Rimantas Liubertas wrote:

[#267266] Re: subject line — Dan Zwell <dzwell@...> 2007/09/02

Devi Web Development wrote:

[#267481] Re: subject line — Bil Kleb <Bil.Kleb@...> 2007/09/04

Chad Perrin wrote:

[#267506] Re: subject line — John Joyce <dangerwillrobinsondanger@...> 2007/09/04

Respectfully, no, unless it's very short. I suggest sort by the To:

[#267510] Re: subject line — "Robert Klemme" <shortcutter@...> 2007/09/04

I vote against, basically because I believe the issue can be solved

[#267514] Re: subject line — "Peter Cooper" <peter@...> 2007/09/04

I vote against. Those with the firehose of ruby-talk gushing into their

[#267282] assigning to hash keys when there is a default value? — 7stud -- <dolgun@...>

Can someone explain why there is a difference in the second line of

41 messages 2007/09/03
[#267283] Re: assigning to hash keys when there is a default value? — dblack@... 2007/09/03

Hi --

[#267286] Re: assigning to hash keys when there is a default value? — 7stud -- <dolgun@...> 2007/09/03

unknown wrote:

[#267310] Re: assigning to hash keys when there is a default value? — Peña, Botp <botp@...> 2007/09/03

From: 7stud -- [mailto:dolgun@excite.com]

[#267330] Re: assigning to hash keys when there is a default value? — 7stud -- <dolgun@...> 2007/09/03

Pe単a, Botp wrote:

[#267335] Re: assigning to hash keys when there is a default value? — "Russell Norris" <rsl@...> 2007/09/03

I don't think this is a bug, kittens. since h[2] returns a value [eventhough it's not set], it causes h[2] to evaluate so the assignmentnever happens. x ||= y just means give me x or set x to y if there'sno value for x. h[2] _does_ have a value if only a default one.

[#267338] Re: assigning to hash keys when there is a default value? — dblack@... 2007/09/03

Hi --

[#267344] Re: assigning to hash keys when there is a default value? — "Russell Norris" <rsl@...> 2007/09/03

I learned that x ||= y means set x to y unless x, so I don't see the

[#267431] Re: assigning to hash keys when there is a default value? — Peña, Botp <botp@...> 2007/09/04

From: sconds@gmail.com [mailto:sconds@gmail.com] On Behalf Of Russell Norris:

[#267511] Re: assigning to hash keys when there is a default value? — "Robert Klemme" <shortcutter@...> 2007/09/04

2007/9/4, Pe, Botp <botp@delmonte-phil.com>:

[#267325] Re: assigning to hash keys when there is a default value? — "Robert Klemme" <shortcutter@...> 2007/09/03

2007/9/3, dblack@wobblini.net <dblack@wobblini.net>:

[#267318] Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...>

Hi guys,

32 messages 2007/09/03
[#267326] Re: Filling individual cells in a grid — "Todd Benson" <caduceass@...> 2007/09/03

On 9/3/07, Joop Van den tillaart <tillaart36@hotmail.com> wrote:

[#267329] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

> With your current code...

[#267341] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

Is there no one else who can help me out a bit?

[#267348] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/03

On Sep 3, 2007, at 8:40 AM, Joop Van den tillaart wrote:

[#267363] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

Wow, thanks for your help...

[#267868] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/06

Joop Van den tillaart wrote:

[#267885] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 7:44 AM, Joop Van den tillaart wrote:

[#267899] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/06

hi thanks for your help,

[#267964] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 11:38 AM, Joop Van den tillaart wrote:

[#267984] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 4:47 PM, Morton Goldberg wrote:

[#268074] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/07

Morton Goldberg wrote:

[#268630] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/11

Hi guys,

[#268645] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

[#268647] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/11

Morton Goldberg wrote:

[#268677] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 7:57 AM, Joop Van den tillaart wrote:

[#268695] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 2:03 PM, Morton Goldberg wrote:

[#268705] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 4:34 PM, Morton Goldberg wrote:

[#267357] with — Matthias Wächter <matthias@...>

Sorry folks if this was raised already, but google is not very

14 messages 2007/09/03

[#267370] wierd floating point output — Matthias Wächter <matthias@...>

Folks,

14 messages 2007/09/03
[#267371] Re: wierd floating point output — dblack@... 2007/09/03

Hi --

[#267373] Re: wierd floating point output — Matthias Wächter <matthias@...> 2007/09/03

On 03.09.2007 19:51, dblack@wobblini.net wrote:

[#267433] Programming Ruby For Newbies — Jin Dynasty <jin.the.miner@...>

Howdy there,

25 messages 2007/09/04

[#267457] Ruby is much slower on linux when compiled with --enable-pthread? — "Adam Kramer" <akramer@...>

Hi,

18 messages 2007/09/04

[#267469] Best IDE for ruby and rails development — AJay Maurya <amaurya@...>

36 messages 2007/09/04
[#267471] Re: Best IDE for ruby and rails development — "Thomas Preymesser" <thopre@...> 2007/09/04

On 04/09/07, AJay Maurya <amaurya@brickred.com> wrote:

[#267476] Re: Best IDE for ruby and rails development — Arthur Murauskas <arthur.murauskas@...> 2007/09/04

On Tuesday 04 September 2007 10:31:23 AJay Maurya wrote:

[#267569] running ruby — yahdoco <yahdoco@...>

Hi Everyone...I am a very new ruby user. I have downloaded ruby to my

28 messages 2007/09/04
[#267574] Re: running ruby — Konrad Meyer <konrad@...> 2007/09/04

On Tuesday 04 September 2007 11:20:05 am yahdoco wrote:

[#267594] Re: running ruby — yahdoco <yahdoco@...> 2007/09/04

I sill have the same two problems:

[#267573] Embedded vs. Non-embedded Tests — Trans <transfire@...>

As far as I know, Facets is the only large project that uses embedded

14 messages 2007/09/04
[#267579] Re: Embedded vs. Non-embedded Tests — "Rick DeNatale" <rick.denatale@...> 2007/09/04

On 9/4/07, Trans <transfire@gmail.com> wrote:

[#267723] Multiple Assignments: Newbie question — "Z T" <zoater@...>

When I run my program:

15 messages 2007/09/05

[#267783] before, after and around Ruby 1.9 — Trans <transfire@...>

Any chance Ruby 1.9 will have before, after and around method

40 messages 2007/09/05
[#267816] Re: before, after and around Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/05

Hi,

[#267825] Re: before, after and around Ruby 1.9 — Joel VanderWerf <vjoel@...> 2007/09/06

Yukihiro Matsumoto wrote:

[#267797] question on bottleneck of ruby — Roger Pack <rogerpack2005@...>

Question: if I made the statement "Ruby is slower than some other

26 messages 2007/09/05
[#267807] Re: question on bottleneck of ruby — khaines@... 2007/09/05

On Thu, 6 Sep 2007, Roger Pack wrote:

[#271288] Re: question on bottleneck of ruby — Roger Pack <rogerpack2005@...> 2007/09/27

Thanks Kirk.

[#271298] Re: question on bottleneck of ruby — "Francis Cianfrocca" <garbagecat10@...> 2007/09/27

On 9/27/07, Roger Pack <rogerpack2005@gmail.com> wrote:

[#267857] Symbols and frozen strings — Brian Candler <B.Candler@...>

I just had a thought.

13 messages 2007/09/06

[#267871] Count and Say (#138) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

21 messages 2007/09/06

[#267941] Is this a bug or a feature? — Martin Jansson <martialis@...>

irb(main):002:0> i=1

13 messages 2007/09/06

[#268006] help me condence my code? — "Simon Schuster" <significants@...>

I know this could be more idiomatic to ruby.

23 messages 2007/09/07

[#268052] read a specific line from a file — Bulhac Mihai <mihai.bulhac@...>

how can i read only a line from a txt file?

18 messages 2007/09/07

[#268108] Netbeans, Eclipse and ruby! How to...? — "André Cardoso" <thyandrecardoso@...>

well, i should start to say that i'm pretty new to ruby!!

15 messages 2007/09/07

[#268307] Bug in lambda? — kevin cline <kevin.cline@...>

This looks like a pretty serious bug. It seems that lambda-

36 messages 2007/09/09
[#268323] Re: Bug in lambda? — dblack@... 2007/09/09

Hi --

[#268485] Re: Bug in lambda? — "Robert Klemme" <shortcutter@...> 2007/09/10

2007/9/9, dblack@wobblini.net <dblack@wobblini.net>:

[#268316] module_function :func vs. MyModule.func? — 7stud -- <dolgun@...>

The following produce the same output:

16 messages 2007/09/09

[#268362] Hash — Ron Green <rongreen1@...>

What is the purpose of string hash? What would you use it for?

21 messages 2007/09/09

[#268403] What Linux distribution to choose for learning Ruby and Ruby on Rails — "Slavo Furman" <slavof@...>

Hi!

82 messages 2007/09/09
[#268413] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/09

-----BEGIN PGP SIGNED MESSAGE-----

[#268418] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Slavo Furman" <slavof@...> 2007/09/09

Thanks for all answers... :)

[#268425] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268427] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Reid Thompson <reid.thompson@...> 2007/09/10

M. Edward (Ed) Borasky wrote:

[#268439] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268444] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Reid Thompson <reid.thompson@...> 2007/09/10

M. Edward (Ed) Borasky wrote:

[#268451] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268545] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Ezra Zygmuntowicz <ezmobius@...> 2007/09/10

Hi~

[#268595] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/11

-----BEGIN PGP SIGNED MESSAGE-----

[#268606] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/11

On Tue, Sep 11, 2007 at 12:00:57PM +0900, M. Edward (Ed) Borasky wrote:

[#268611] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/11

-----BEGIN PGP SIGNED MESSAGE-----

[#268614] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — bob@... (Bob Proulx) 2007/09/11

M. Edward (Ed) Borasky wrote:

[#268405] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Marcin Raczkowski <mailing.mr@...> 2007/09/09

Slavo Furman wrote:

[#268750] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — hemant <gethemant@...> 2007/09/12

On 9/10/07, Marcin Raczkowski <mailing.mr@gmail.com> wrote:

[#269173] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Shot (Piotr Szotkowski)" <shot@...> 2007/09/15

hemant:

[#269182] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Todd Benson" <caduceass@...> 2007/09/15

On 9/15/07, Shot (Piotr Szotkowski) <shot@hot.pl> wrote:

[#269199] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/15

Todd Benson wrote:

[#268433] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Trans <transfire@...> 2007/09/10

[#268436] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268447] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Trans <transfire@...> 2007/09/10

[#268513] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Mon, Sep 10, 2007 at 12:07:42PM +0900, Trans wrote:

[#268517] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Lionel Bouton <lionel-subscription@...> 2007/09/10

Chad Perrin wrote the following on 10.09.2007 18:46 :

[#268539] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 01:54:42AM +0900, Lionel Bouton wrote:

[#268557] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Lionel Bouton <lionel-subscription@...> 2007/09/10

Thanks for the answer, that was an interesting reading. I've some

[#268565] Re: [OT] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 05:38:32AM +0900, Lionel Bouton wrote:

[#268570] Re: [OT] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 07:00:50AM +0900, Chad Perrin wrote:

[#268658] undefined method `+' for nil:NilClass (NoMeth — Mahen Surinam <neoanderson12@...>

Dear All,

14 messages 2007/09/11

[#268663] Camping or Merb — "Eduardo Tongson" <propolice@...>

Hi folks,

19 messages 2007/09/11

[#268672] Graphics... why so shrouded in mystery? — Weston Campbell <silvershockwave@...>

I've been working with ruby for quite a while now, and I still don't

13 messages 2007/09/11

[#268761] what is this syntax: \001\002 ? — 7stud -- <dolgun@...>

Hi,

15 messages 2007/09/12

[#268786] copy/paste line numbers with code — Max Williams <toastkid.williams@...>

I'm writing up my project report and want to include line numbers with

12 messages 2007/09/12

[#268802] IronRuby — Lloyd Linklater <lloyd@2live4.com>

I have heard disturbing things about IronRuby. The short version is

36 messages 2007/09/12
[#268828] Re: IronRuby — Greg Donald <greg@...> 2007/09/12

On Thu, 13 Sep 2007, Lloyd Linklater wrote:

[#268833] Re: IronRuby — "Felix Windt" <fwmailinglists@...> 2007/09/12

> -----Original Message-----

[#268911] Re: IronRuby — Charles Oliver Nutter <charles.nutter@...> 2007/09/13

Bill Kelly wrote:

[#268918] Debug — "coolgeng coolgeng" <coolgeng410@...>

With the Rails, I build a project connecting the MySQL. But When I change

17 messages 2007/09/13

[#268970] Cross-platform Home Directory? — Trans <transfire@...>

I have a little app that needs to store session data. I assume the

19 messages 2007/09/13

[#269047] IP to Country (#139) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

32 messages 2007/09/14

[#269063] How many computers in the house? — Todd Burch <promos@...>

I went to the Lone Star Ruby Conference last week. 7 of us went out to

41 messages 2007/09/14

[#269125] Unicode — Zephyr Pellerin <ztz@...>

I hate to discuss something related to the development timeline, I know

26 messages 2007/09/15
[#270180] Re: Unicode — "Michal Suchanek" <hramrach@...> 2007/09/21

On 15/09/2007, Zephyr Pellerin <ztz@nxvr.org> wrote:

[#269140] one line to print the statement AS WELL AS the evaluated value like in C — kendear <summercoolness@...>

i wonder in Ruby, is there a line method to do something like in C

11 messages 2007/09/15

[#269214] Newbie help — Ali Koubeissi <ali.koubeissi@...>

Hey, I've started with Ruby two days ago, and I have some questions.

19 messages 2007/09/16

[#269251] Ruby Forum > Ruby Talk > comp.lang.ruby ? — Kenneth LL <kenneth.kin.lum@...>

so it seems like Google created Ruby Talk and anything posted to Ruby

25 messages 2007/09/16

[#269315] Newbie: what's Ruby idiom for word-by-word input? — Alex Shulgin <alex.shulgin@...>

Hi,

16 messages 2007/09/16
[#269326] Re: Newbie: what's Ruby idiom for word-by-word input? — Robert Klemme <shortcutter@...> 2007/09/16

On 16.09.2007 21:08, Alex Shulgin wrote:

[#269407] Re: Newbie: what's Ruby idiom for word-by-word input? — Alex Shulgin <alex.shulgin@...> 2007/09/17

On Sep 17, 12:19 am, Robert Klemme <shortcut...@googlemail.com> wrote:

[#269441] Re: Newbie: what's Ruby idiom for word-by-word input? — William James <w_a_x_man@...> 2007/09/17

On Sep 17, 4:30 am, Alex Shulgin <alex.shul...@gmail.com> wrote:

[#269357] Tk Ruby / Fx Ruby / Wx Ruby — "Jayson Williams" <williams.jayson@...>

I have looked at these three GUI's for Ruby, and would like to know

12 messages 2007/09/17

[#269440] group array elements in groups of two — Emmanuel Oga <oga_emmanuel_oga@...>

A better way to do this? :

13 messages 2007/09/17

[#269450] how to use tuple as hash key — SpringFlowers AutumnMoon <summercoolness@...>

in Python, a hash key cannot be [1,2,3] but must be (1,2,3), a tuple.

13 messages 2007/09/17
[#269453] Re: how to use tuple as hash key — Stefano Crocco <stefano.crocco@...> 2007/09/17

Alle luned狸 17 settembre 2007, SpringFlowers AutumnMoon ha scritto:

[#269562] The meaning of a = b in object oriented languages — Summercool <Summercoolness@...>

30 messages 2007/09/18

[#269596] finding string matches, in order, in a file — Peter Bailey <pbailey@...>

Hi,

19 messages 2007/09/18
[#269601] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

[#269605] Re: finding string matches, in order, in a file — Peter Bailey <pbailey@...> 2007/09/18

William James wrote:

[#269627] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

On Sep 18, 8:28 am, Peter Bailey <pbai...@bna.com> wrote:

[#269631] Re: finding string matches, in order, in a file — Peter Bailey <pbailey@...> 2007/09/18

William James wrote:

[#269637] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

On Sep 18, 10:27 am, Peter Bailey <pbai...@bna.com> wrote:

[#269616] CPU Usage not near 100% when running code — SpringFlowers AutumnMoon <summercoolness@...>

I tested some computation intensive Ruby code. When running, the CPU

11 messages 2007/09/18

[#269732] How to print FULL stacktrace of exception w/ line #? — Andrew Chen <meihome@...>

The ruby interpreter prints out a full trace of the exception.

12 messages 2007/09/19

[#269779] how can I remove all the comments in my c program. — Vellingiri Arul <hariharan.spc@...>

Dear Friends,

25 messages 2007/09/19

[#269813] YAML & readlines & modify text files — Dan George <endege@...>

Hello,

16 messages 2007/09/19
[#269834] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269879] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 5:27 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269888] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269910] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 9:22 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269913] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269925] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 11:03 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269816] How to compute Sunrise / Sunset ? — Joe Joe <joepetrini@...>

I need to compute sunrise/set times in ruby for a given long lat. Does

12 messages 2007/09/19

[#269862] special Array method about Unix pathes — unbewusst.sein@... (Une B騅ue)

15 messages 2007/09/19

[#269873] scraping web pages for cisco products — Chuck Dawit <chuckdawit@...>

16 messages 2007/09/19

[#269902] Do C Extensions Block Ruby? — "Wayne E. Seguin" <wayneeseguin@...>

Does a C extension running in a ruby-thread block all ruby threads

16 messages 2007/09/19
[#269904] Re: Do C Extensions Block Ruby? — Nobuyoshi Nakada <nobu@...> 2007/09/19

Hi,

[#269924] Re: Do C Extensions Block Ruby? — Joel VanderWerf <vjoel@...> 2007/09/19

Nobuyoshi Nakada wrote:

[#269971] Is there any separate editor for ruby? — Vellingiri Arul <hariharan.spc@...>

Hai Friends,

13 messages 2007/09/20

[#270018] Idiomatic Ruby for Array#extract / Range#length? — "Sammy Larbi" <sam@...>

During the monthly meeting of our code dojo, we were surprised by a couple

27 messages 2007/09/20
[#270039] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 2:28 PM, Sammy Larbi wrote:

[#270047] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Xavier Noria <fxn@hashref.com> wrote:

[#270051] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 5:39 PM, Rick DeNatale wrote:

[#270056] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Xavier Noria <fxn@hashref.com> wrote:

[#270065] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#270084] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 7:26 PM, Rick DeNatale wrote:

[#270110] I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Ruby Maniac <raychorn@...>

I am new to Ruby and I could use some expert advice as to how I can

62 messages 2007/09/20
[#270145] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Brian Adkins <lojicdotcom@...> 2007/09/21

On Sep 20, 6:02 pm, Ruby Maniac <raych...@hotmail.com> wrote:

[#270149] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — John Joyce <dangerwillrobinsondanger@...> 2007/09/21

[#270236] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Ruby Maniac <raychorn@...> 2007/09/21

On Sep 20, 7:16 pm, John Joyce <dangerwillrobinsondan...@gmail.com>

[#270239] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Todd Benson" <caduceass@...> 2007/09/21

On 9/21/07, Ruby Maniac <raychorn@hotmail.com> wrote:

[#270305] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Nobuyoshi Nakada" <nobu@...> 2007/09/22

Hi,

[#270575] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Ilmari Heikkinen" <ilmari.heikkinen@...> 2007/09/24

On 9/22/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:

[#270115] How fast does your Ruby run? — SpringFlowers AutumnMoon <summercoolness@...>

How fast does your Ruby run?

114 messages 2007/09/20
[#270118] Re: How fast does your Ruby run? — Todd Burch <promos@...> 2007/09/20

SpringFlowers AutumnMoon wrote:

[#270167] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/09/21

Todd Burch wrote:

[#270168] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/09/21

Charles Oliver Nutter wrote:

[#270182] Re: How fast does your Ruby run? — gga <GGarramuno@...> 2007/09/21

Seems like a pretty silly test, but okay...

[#270468] Re: How fast does your Ruby run? — David Orriss Jr <codethought@...> 2007/09/23

SpringFlowers AutumnMoon wrote:

[#276142] Re: How fast does your Ruby run? — Daniel Schömer <daniel.schoemer@...> 2007/10/27

Gentoo Linux on Intel Pentium 4 2.40GHz (512 KB cache):

[#276152] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/10/27

Daniel Scher wrote:

[#276153] Re: How fast does your Ruby run? — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/27

Charles Oliver Nutter wrote:

[#276191] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/10/27

M. Edward (Ed) Borasky wrote:

[#270161] Re: [ANN] Metadata 1.0-rc2 — Peña, Botp <botp@...>

From: Ilmari Heikkinen [mailto:ilmari.heikkinen@gmail.com]

6 messages 2007/09/21

[#270245] CplusRuby - Gluing C and Ruby — Michael Neumann <mneumann@...>

Hi all,

22 messages 2007/09/21

[#270320] sequel problem: no such file to load -- mysql (LoadError) — Michael Andreasen <ventosus@...>

Hi, i tried to learn about sequel (and Ruby) and got this problem

10 messages 2007/09/22

[#270377] Getting started with Ruby (noob confusion) — Nunya Business <sasnso4a5w12kb8@...>

Hi everyone!

16 messages 2007/09/22

[#270451] Recent Criticism about Ruby (Scalability, etc.) — "forrie@..." <forrie@...>

I presume most people here read today's article on Slashdot which had

80 messages 2007/09/23
[#270729] Re: Recent Criticism about Ruby (Scalability, etc.) — "Phlip" <phlip2005@...> 2007/09/25

> I presume most people here read today's article on Slashdot

[#270760] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/09/25

On Tue, Sep 25, 2007 at 01:04:21PM +0900, Phlip wrote:

[#270789] Re: Recent Criticism about Ruby (Scalability, etc.) — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 1:15 am, Chad Perrin <per...@apotheon.com> wrote:

[#271162] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/09/26

On Tue, Sep 25, 2007 at 10:40:04PM +0900, Ruby Maniac wrote:

[#272380] Re: Recent Criticism about Ruby (Scalability, etc.) — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Chad Perrin wrote:

[#272394] Re: Recent Criticism about Ruby (Scalability, etc.) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

Charles Oliver Nutter wrote:

[#272398] Re: Recent Criticism about Ruby (Scalability, etc.) — benjohn@... 2007/10/03

[#272405] Re: Recent Criticism about Ruby (Scalability, etc.) — MenTaLguY <mental@...> 2007/10/03

On Thu, 4 Oct 2007 00:19:40 +0900, benjohn@fysh.org wrote:

[#272412] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/10/03

On Thu, Oct 04, 2007 at 12:38:25AM +0900, MenTaLguY wrote:

[#272426] Re: Recent Criticism about Ruby (Scalability, etc.) — MenTaLguY <mental@...> 2007/10/03

On Thu, 4 Oct 2007 01:42:22 +0900, Chad Perrin <perrin@apotheon.com> wrote:

[#272439] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/10/03

On Thu, Oct 04, 2007 at 02:39:28AM +0900, MenTaLguY wrote:

[#270924] Re: Recent Criticism about Ruby (Scalability, etc.) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/26

Chad Perrin wrote:

[#270482] how to use Ruby / Tk to display a text message status box — SpringFlowers AutumnMoon <summercoolness@...>

how can we pop up a Tk window to display the temporary results of a

17 messages 2007/09/23
[#270980] Re: how to use Ruby / Tk to display a text message status box — Summercool <Summercoolness@...> 2007/09/26

[#270508] This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Ruby Maniac <raychorn@...>

I welcome any corrections anyone might be able to make since I am new

60 messages 2007/09/24
[#270524] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Phrogz <phrogz@...> 2007/09/24

On Sep 23, 8:50 pm, Ruby Maniac <raych...@hotmail.com> wrote:

[#270531] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — John Joyce <dangerwillrobinsondanger@...> 2007/09/24

Why do people troll?

[#270535] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Mohit Sindhwani <mo_mail@...> 2007/09/24

John Joyce wrote:

[#270557] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — benjohn@... 2007/09/24

> John Joyce wrote:

[#270597] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Chad Perrin <perrin@...> 2007/09/24

On Mon, Sep 24, 2007 at 06:34:57PM +0900, benjohn@fysh.org wrote:

[#270599] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/24

Chad Perrin wrote:

[#270727] Re: This is why Ruby 1.8.6 can never be made to run anywhere — 7stud -- <dolgun@...> 2007/09/25

Bill Kelly wrote:

[#270532] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "Michael T. Richter" <ttmrichter@...> 2007/09/24

Can I ask why *ANYBODY* took a message by someone calling themselves

[#270536] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/24

Michael T. Richter wrote:

[#270542] "myscript.rb " - there's a blank in my name! — Todd Burch <promos@...>

On a Mac - Tiger 10.4.10.

13 messages 2007/09/24

[#270596] best way to 'hide' a method when method_missing is in town — "Kevin Barnes" <vinbarnes@...>

I am trying to hide a method in a subclass whose base class has

11 messages 2007/09/24

[#270663] Favorite idiom for "keep doing this until it returns nil/false" — Phrogz <phrogz@...>

I want to keep running gsub! on a string until it returns nil. How do

12 messages 2007/09/24

[#270708] object_id 1, 2, 3 — SpringFlowers AutumnMoon <summercoolness@...>

Fixnum object_id

15 messages 2007/09/25

[#270788] I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...>

I love Ruby but what is the deal with the lack of a VM ?

25 messages 2007/09/25
[#270791] Re: I love Ruby but what is the deal with... this ! — Gregory Seidman <gsslist+ruby@...> 2007/09/25

On Tue, Sep 25, 2007 at 10:35:06PM +0900, Ruby Maniac wrote:

[#270794] Re: I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 6:52 am, Gregory Seidman <gsslist+r...@anthropohedron.net>

[#270815] Re: I love Ruby but what is the deal with... this ! — "Walter Purvis" <wpmailinglists@...> 2007/09/25

Troll.

[#270867] Re: I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 8:23 am, "Walter Purvis" <wpmailingli...@gmail.com> wrote:

[#270872] Re: I love Ruby but what is the deal with... this ! — Phlip <phlip2005@...> 2007/09/25

> Do you classify all those who have an opposing viewpoint as being a

[#270792] Ruby Scales just fine ! — Ruby Maniac <rubymaniac@...>

Just buy a bunch of Quad Core Opterons and get over it !

24 messages 2007/09/25
[#270800] Re: Ruby Scales just fine ! — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/25

Ruby Maniac wrote:

[#270842] Re: Ruby Scales just fine ! — Eric Hodel <drbrain@...7.net> 2007/09/25

On Sep 25, 2007, at 07:22 , M. Edward (Ed) Borasky wrote:

[#270813] Why dynamic languages for ActiveRecord..? — ypomonh <ypomonh@...>

I having problems understanding why people prefer to implement the

14 messages 2007/09/25

[#270888] The guy who wrote RubyScript2Exe needs to seriously reconsider how this little "gem" works... — Ruby Maniac <rubymaniac@...>

I have a very simple Ruby script that does nothing more than compute

13 messages 2007/09/25

[#270916] ruby regex on html file — eggie5 <eggie5@...>

I'm trying to write a rake task to extract all the script tags out of

12 messages 2007/09/25

[#270966] Feature request for RubyScript2Exe — Ruby Maniac <rubymaniac@...>

It would be nice if RubyScript2Exe was able to handle a passworded ZIP

11 messages 2007/09/26

[#270989] Detecting number ranges — Jay Levitt <jay+news@...>

I had to write a script this evening to take an unsorted input file of the

17 messages 2007/09/26

[#271046] Finding the last Sunday of a month — Peter Bailey <pbailey@...>

Hello,

31 messages 2007/09/26
[#271050] Re: Finding the last Sunday of a month — Yossef Mendelssohn <ymendel@...> 2007/09/26

On Sep 26, 8:44 am, Peter Bailey <pbai...@bna.com> wrote:

[#271078] Recursing through directories — Gabriel Dragffy <gabe@...>

Hi there

14 messages 2007/09/26

[#271089] OneClickInstaller/RubyGems problems — Trans <transfire@...>

Is there anything you have to do after installing the Windows

16 messages 2007/09/26

[#271143] Confession: I never learned CS — Jay Levitt <jay+news@...>

I was thinking about my "Detecting number ranges" question and the various

24 messages 2007/09/26
[#271317] Re: Confession: I never learned CS — Jay Levitt <jay+news@...> 2007/09/27

On Thu, 27 Sep 2007 23:57:08 +0900, Ilmari Heikkinen wrote:

[#271147] Syntax for <stringVariable>.new ? — Larry Fast <lfast@...>

Hi Rubyists and ...istas,

14 messages 2007/09/26
[#271148] Re: Syntax for <stringVariable>.new ? — Sebastian Hungerecker <sepp2k@...> 2007/09/26

Larry Fast wrote:

[#271212] Confession: I never did ASM — julik <listbox@...>

I would love to join the recently started confession fest.

57 messages 2007/09/27
[#271220] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/27

julik wrote:

[#271279] Re: [OT] Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/27

[#271393] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/28

John Joyce wrote:

[#271403] Re: [OT] Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/28

[#271412] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/28

John Joyce wrote:

[#271672] Re: Confession: I never did ASM — Brian Adkins <lojicdotcom@...> 2007/09/29

On Sep 27, 1:21 am, julik <list...@julik.nl> wrote:

[#271695] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/29

[#272303] Re: Confession: I never did ASM — Brian Adkins <lojicdotcom@...> 2007/10/03

On Sep 29, 3:27 pm, John Joyce <dangerwillrobinsondan...@gmail.com>

[#272307] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/10/03

[#272309] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

John Joyce wrote:

[#272322] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/10/03

[#272325] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

John Joyce wrote:

[#272423] Re: Confession: I never did ASM — Chad Perrin <perrin@...> 2007/10/03

On Wed, Oct 03, 2007 at 02:08:02PM +0900, M. Edward (Ed) Borasky wrote:

[#272508] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/04

Chad Perrin wrote:

[#271356] is there to invoke 'previous' in Find? (or refresh the current path?) — "dtown22@..." <dtown22@...>

I am writing a small script which recursively goes down a dir

10 messages 2007/09/27

[#271360] mac - hpricot problems — Sergio Ruiz <sergio@...>

i am trying to get hpricot running (so i can run mechanize) and am

24 messages 2007/09/27
[#271368] Re: mac - hpricot problems — Daniel Waite <rabbitblue@...> 2007/09/27

Sergio Ruiz wrote:

[#271370] Re: mac - hpricot problems — Sergio Ruiz <sergio@...> 2007/09/28

[#271376] Re: mac - hpricot problems — Ryan Davis <ryand-ruby@...> 2007/09/28

[#271364] Re: Anyone interested In IronRuby — Phrogz <phrogz@...>

On Sep 26, 11:47 pm, IronRuby <rubyguja...@gmail.com> wrote:

12 messages 2007/09/27

[#271394] dike-0.0.1 - a memory leak detector — "ara.t.howard" <ara.t.howard@...>

19 messages 2007/09/28
[#271522] Re: [ANN] dike-0.0.1 - a memory leak detector — Joel VanderWerf <vjoel@...> 2007/09/28

ara.t.howard wrote:

[#271526] Re: [ANN] dike-0.0.1 - a memory leak detector — "ara.t.howard" <ara.t.howard@...> 2007/09/28

[#271467] Probable Iterations (#141) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

15 messages 2007/09/28

[#271472] Windows - Get current logged user — Rodrigo Bermejo <rodrigo.bermejo@...>

14 messages 2007/09/28

[#271499] a different type of reference (shocked) — SpringFlowers AutumnMoon <summercoolness@...>

Before, when I say Ruby's reference to an object

14 messages 2007/09/28

[#271617] how can I start a shell process and return immediately? — Stephen Bannasch <stephen.bannasch@...>

I want to start a Java program from a Ruby program and have the Java

16 messages 2007/09/29
[#341070] Re: how can I start a shell process and return immediately? — Enling Li <enling.li@...> 2009/07/09

I have another quetion related to fire off a back ground shell process

[#271649] Is there a combination of a struct and an array? I wanna iterate over all created objects from a certain struct-class (I guess). — kazaam <kazaam@...>

I have a file with many entries and much of these I don't need. Let's imagine:

8 messages 2007/09/29

[#271673] a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...>

when we say

57 messages 2007/09/29
[#271677] Re: a = Dog.new # a is not a pointer and not a reference? — Morton Goldberg <m_goldberg@...> 2007/09/29

On Sep 29, 2007, at 1:16 PM, SpringFlowers AutumnMoon wrote:

[#271698] Re: a = Dog.new # a is not a pointer and not a reference? — "Austin Ziegler" <halostatue@...> 2007/09/29

On 9/29/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:

[#271718] Re: a = Dog.new # a is not a pointer and not a reference? — Joel VanderWerf <vjoel@...> 2007/09/29

Austin Ziegler wrote:

[#271804] Re: a = Dog.new # a is not a pointer and not a reference? — "Austin Ziegler" <halostatue@...> 2007/09/30

On 9/29/07, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:

[#271732] Re: a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...> 2007/09/30

Austin Ziegler wrote:

[#271734] Re: a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...> 2007/09/30

SpringFlowers AutumnMoon wrote:

[#271740] Re: a = Dog.new # a is not a pointer and not a reference? — Morton Goldberg <m_goldberg@...> 2007/09/30

On Sep 29, 2007, at 8:18 PM, SpringFlowers AutumnMoon wrote:

[#271738] Newbie needs help getting user input — Peter Vanderhaden <bostonantifan@...>

I'm trying to learn Ruby and trying to convert a Perl program at the

14 messages 2007/09/30

[#271776] Can you please help to make decision? — Byung-Hee HWANG <bh@...>

Fist of all, sorry for poor English, I am not professional English

34 messages 2007/09/30
[#271808] Re: Can you please help to make decision? — 7stud -- <dolgun@...> 2007/09/30

I would choose python.

[#271784] which language allows you to change an argument's value? — Summercool <Summercoolness@...>

34 messages 2007/09/30

Re: [QUIZ] Twisting a Rope (#137)

From: "Gustav Munkby" <grddev@...>
Date: 2007-09-03 09:42:49 UTC
List: ruby-talk #267314
On 8/31/07, Ruby Quiz <james@grayproductions.net> wrote:
> by John Miller
>
> This week's task is to implement the Rope data structure as a Ruby class.  This
> topic comes out of the ICFP programming competition
> (http://www.icfpcontest.com/) which had competitors manipulating a 7.5 million
> character string this year.

My solution deviates slightly from the problem specification.
The most important difference is that instead of implementing
a binary tree to store the strings, they are all stored in an
array instead.

The class itself is quite long, since I wanted to implement
many of the methods of the built-in String class. Some of the
methods will require significant work to actually implement.
Most notably the Regexp-related methods, since there is no
way to instruct the Regexp matcher to ask for more characters
once it has reached the end of a string.

Actually, all String methods are implemented, by implementing
method missing and delegating to the composed string if the
string class can handle the method. After delegating to the
string class, we convert any String result to a new rope and
we also make sure to replace our content by the string we
delegated to, to make sure that destructive methods works as
expected.

In fact, we replace the content of our rope as soon as to_s
is called. since the reason for  lazy concatenation is to
avoid the concatenation cost, we can just as well keep the
concatenated string when we already had to pay the price.

The benchmark results are:

# String
Build:   0.170000   0.150000   0.320000 (  0.324341)
Sort:   3.470000   3.630000   7.100000 (  7.126741)

# ArrayRope
Build:   0.010000   0.010000   0.020000 (  0.009744)
Sort:   0.130000   0.000000   0.130000 (  0.138330)

# ArrayRope (with dup)
Build:   0.240000   0.160000   0.400000 (  0.402201)
Sort:   0.160000   0.000000   0.160000 (  0.163022)

For the unprotected case, sorting was ~52 times faster,
and building was ~33 times faster.

However, since the string class is not immutable, there is a
slight problem with this approach. The strings could added
to the rope could be modified "under the hood". We can easily
protect against that by making copies of the strings when we
add them to the rope. Since the built-in String shares the
actual data between the two instances (until they change),
this is not so much of a memory issue as one could expect.

By adding dup (in initialize/append/prepend) we end up with
the following times, which trades of some of our speed/memory
for a bit of safety. (This is actually the submitted solution)

Compared with the string approach, building is now (for obvious
reasons) slower than the String, but only about 25%.
Sorting is still much faster than the String case, namely ~44
times as fast.

!g

Attachments (1)

array_rope.rb (5.45 KB, text/x-ruby)
class Array
  def upper_bound(value)
    lo, hi = 0, size-1
    while lo <= hi
  	  mid = (lo + hi) / 2
  	  if value >= at(mid)
	      lo = mid + 1
  	  else
	      hi = mid - 1
  	  end
  	end
    lo
  end
end

class ArrayRope
  attr_reader :segments
  def initialize(*segments)
    raise segments.inspect if segments.any? { |s| s.nil? }
    @segments = segments.map { |s| s.dup }
    compute_offsets
  end

  def compute_offsets
    l = 0
    @offsets = @segments.map { |s| l += s.length }
    @offsets.unshift 0    
  end

  def length
    @offsets.last
  end
  alias :size :length
  def empty?
    @segments.empty?
  end

  def to_s
    case @segments.size
    when 0; ""
    when 1; @segments.first.dup
    else
      # When converting to a string, we must do the expensive
      # concatenation, so lets hijack that information and use the
      # new string internally as well.
      s = (@segments * "")
      @segments, @offsets = [s], [0,s.length]
      s.dup
    end
  end
  
  def method_missing(m, *args, &block)
    # Make sure we handle remaining string methods accordingly
    if "".respond_to?(m)
      s = to_s
      r = s.__send__(m, *args, &block)

      # Guess that this is the right thing to do
      if r.equal? s
        r = self 
      elsif r.is_a? String
        r = ArrayRope.new r
      end

      # The method might change the contents of the string
      replace s

      r
    else
      super(m, *args, &block)
    end
  end
  
  def responds_to?(m)
    # Make sure we handle remaining string methods accordingly
    super || "".responds_to?(m)
  end
  
  def append(*segments)
    segments.each do |s|
      if s.is_a? ArrayRope
        append *s.segments
      elsif !s.empty?
        @segments << s.dup
        @offsets << @offsets.last + s.length
      end
    end
    self
  end
  alias :<< :append
  def prepend(*segments)
    segments.each do |s|
      if s.is_a? ArrayRope
        prepend *s.segments
      elsif !s.empty?
        @segments.unshift s.dup
        compute_offsets
      end
    end
    self
  end
  
  def slice(start,length=nil)
    return to_s.slice(start, length||0) if start.is_a? Regexp
    return index(start) if start.is_a? String
    if !length && start.is_a?(Range)
      length = start.last - start.first - (exclude_end? ? 1 : 0)
      start = start.first
    end
    start = self.length + start if start < 0
    if start < 0 || start > self.length
      nil
    elsif !length
      @segments.detect { |s| (start -= s.length) < 0 }.slice(start)
    else
      index = @offsets.upper_bound(start) - 1
      rope = ArrayRope.new(
        @segments.at(index).slice(start - @offsets.at(index), length))
      remain = length - rope.length
      while remain > 0 && (index += 1) < @segments.length
        rope << @segments.at(index).slice(0, remain)
        remain = length - rope.length
      end
      rope
    end
  end
  alias :[] :slice
  
  def dup; ArrayRope.new(*@segments); end
  alias :clone :dup
  
  def +(other); dup << other; end

  include Enumerable
  def each &block
    last = nil
    @segments.each do |s|
      s.each do |l|
        if l[-1] == ?\n
          yield(last ? "#{last}#{l}" : l)
          last = nil
        else
          last = "#{last}#{l}"
        end
      end
    end
    yield last if last
    self
  end
  def each_byte &block
    @segments.each { |s| s.each_byte &block }
    self
  end

  include Comparable
  %w[<=> casecmp].each do |m|
    module_eval <<-EOM
      def #{m}(other)
        result = 0
        @segments.zip(@offsets) do |segment,offset|
          result = other.slice(offset, segment.length).#{m}(segment)
          break if result != 0
        end
        -result
      end
    EOM
  end
  def ==(other)
    @offsets.last == other.length && (self <=> other) == 0
  end
  alias :eql? :==
  
  def hash; @segments.inject(0) { |h, s| h + s.hash }; end

  def replace str
    @segments, @offsets = [], [0]
    append str
  end

  %w[downcase upcase capitalize swapcase].each do |m|
    module_eval <<-EOM
      def #{m}!
        @segments.inject(nil) do |r,s|
          s.#{ m }! ? self : r
        end
      end
    EOM
  end
  
  def rstrip!
    while @segments.last.rstrip!
      if @segments.last.empty?
        @segments.pop
        @offsets.pop
      else
        @offsets[-1] = @offsets[-2] + @segments[-1].length
        return self
      end
    end
  end

  def lstrip!
    while @segments.first.lstrip!
      if @segments.first.empty?
        @segments.shift
      else
        compute_offsets
        return self
      end
    end
  end

  def strip!
    rstrip! ? lstrip! || self : lstrip!
  end

  def chop!
    unless @segments.empty?
      if @segments.last.chop!
        if @segments.last.empty?
          @segments.pop
          @offsets.pop
        else
          @offsets[-1] -= 1
        end
        return self
      end
    end
  end
  
  def chomp!(sep=$/)
    unless @segments.empty?
      if @segments.last.chomp!(sep)
        if @segments.last.empty?
          @segments.pop
          @offsets.pop
        else
          @offsets[-1] -= 1
        end
        return self
      end
    end
  end
  
  def next!
    (@segments.length-1).downto(0) do |i|
      s = @segments.at(i)
      n = s.next
      r = n.length > s.length
      s.replace n
      s.slice!(-1) if r && i > 0
      break unless r
    end
    self
  end

  %w[downcase upcase capitalize swapcase lstrip rstrip strip chop chomp next].each do |m|
    module_eval <<-EOM
      def #{m}strip
        d = dup
        d.#{m}strip!
        d
      end
    EOM
  end
end

In This Thread