[#140667] Thinking of creating a small mini-language-interpreter using Ruby — Glenn Smith <glenn.ruby@...>

Always something I've wanted to write - an interpreter of my own. Now

12 messages 2005/05/01

[#140714] Ruby, Rails and now og — "Andrew Ballantine" <andrew.ballantine@...>

Hi,

16 messages 2005/05/02

[#140808] Re: "Bounty" approach for small pieces of code? — Hal Fulton <hal9000@...>

Molitor, Stephen L wrote:

12 messages 2005/05/03
[#140810] Re: "Bounty" approach for small pieces of code? — Richard Lyman <lymans@...> 2005/05/03

On 5/2/05, Hal Fulton <hal9000@hypermetrics.com> wrote:

[#140856] Bug Tracker — Andy Stone <xsltguru@...>

Hello all,

28 messages 2005/05/03

[#140910] Typo-checking instead of static typing — Ben Giddings <bg-rubytalk@...>

Once again, static typing reared its head on the mailing list, and once

31 messages 2005/05/03

[#140928] Re: [ANN] traits-0.0.0 — "Berger, Daniel" <Daniel.Berger@...>

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

16 messages 2005/05/03

[#141015] writing to a file with gsub! — Ralf Mler <r_mueller@...>

Hi,

12 messages 2005/05/04

[#141023] Object#inside_metaclass? — "Ara.T.Howard" <Ara.T.Howard@...>

56 messages 2005/05/04
[#141045] Re: [RCR] Object#inside_metaclass? — "David A. Black" <dblack@...> 2005/05/04

On Wed, 4 May 2005, Ara.T.Howard wrote:

[#141050] Re: [RCR] Object#inside_metaclass? — Ilias Lazaridis <ilias@...> 2005/05/04

David A. Black wrote:

[#141522] Re: [RCR] Object#inside_metaclass? — Yukihiro Matsumoto <matz@...> 2005/05/07

Hi,

[#141533] Re: [RCR] Object#inside_metaclass? — Ilias Lazaridis <ilias@...> 2005/05/07

Yukihiro Matsumoto wrote:

[#141548] Re: [RCR] Object#inside_metaclass? — Yukihiro Matsumoto <matz@...> 2005/05/07

In message "Re: [RCR] Object#inside_metaclass?"

[#141550] Re: [RCR] Object#inside_metaclass? — Ilias Lazaridis <ilias@...> 2005/05/07

Yukihiro Matsumoto wrote:

[#141575] Re: [RCR] Object#inside_metaclass? — Yukihiro Matsumoto <matz@...> 2005/05/07

[#141057] Fixnum's binary representation — camsight@...

Hi, people!

13 messages 2005/05/04

[#141143] Re: object reference handle (like perl's reference to scalar) — Eric Mahurin <eric_mahurin@...>

> > In ruby, is there a way to get a handle of an object

17 messages 2005/05/04

[#141165] Ruby Editor Plugin for jEdit 0.6 - method completion release — "Rob ." <rob.02004@...>

Version 0.6 of jEdit's Ruby Editor Plugin has been released and is

21 messages 2005/05/05
[#141176] Re: [ANN] Ruby Editor Plugin for jEdit 0.6 - method completion release — Alexandru Popescu <the_mindstorm@...> 2005/05/05

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

[#141186] Re: [ANN] Ruby Editor Plugin for jEdit 0.6 - method completion release — "Rob ." <rob.02004@...> 2005/05/05

Alexandru Popescu wrote:> Rob . said:> > Version 0.6 of jEdit's Ruby Editor Plugin has been released and is> > available for download!> >> > http://www.jedit.org/ruby/> > Great job Rob!Mulmesc!

[#141205] Re: [ANN] Ruby Editor Plugin for jEdit 0.6 - method completion release — Tom Copeland <tom@...> 2005/05/05

On Thu, 2005-05-05 at 18:38 +0900, Rob . wrote:

[#141219] Re: [ANN] Ruby Editor Plugin for jEdit 0.6 - method completion release — Alexandru Popescu <the_mindstorm@...> 2005/05/05

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

[#141225] Re: [ANN] Ruby Editor Plugin for jEdit 0.6 - method completion release — "Rob ." <rob.02004@...> 2005/05/05

Alex, I don't get an exception in this case, but I see what you mean.

[#141196] Whats so different about a Hash? — Andrew Walrond <andrew@...>

Consider:

15 messages 2005/05/05
[#141197] Re: Whats so different about a Hash? — Brian Schrer <ruby.brian@...> 2005/05/05

On 05/05/05, Andrew Walrond <andrew@walrond.org> wrote:

[#141199] Re: Whats so different about a Hash? — Andrew Walrond <andrew@...> 2005/05/05

Hi Brian,

[#141299] another Tk question — Joe Van Dyk <joevandyk@...>

In Tk, what's the best way to show a large table of data that gets

15 messages 2005/05/05
[#141326] Re: another Tk question — Hidetoshi NAGAI <nagai@...> 2005/05/06

From: Joe Van Dyk <joevandyk@gmail.com>

[#141307] String Manipulation Nuby Question — Chris Roos <chris@...>

I have a Person with title, forename and surname (all of which are

13 messages 2005/05/05

[#141311] Ruby Editor Plugin for jEdit 0.6.1 - method completion release II — "Rob ." <rob.02004@...>

Version 0.6.1 of jEdit's Ruby Editor Plugin has been released and is

12 messages 2005/05/05

[#141334] RCR 303: nil should accept missing methods and return nil — John Carter <john.carter@...>

A very simple and generic way of improving the reliability of Ruby

66 messages 2005/05/06
[#141338] Re: RCR 303: nil should accept missing methods and return nil — Luke Graham <spoooq@...> 2005/05/06

On 5/6/05, John Carter <john.carter@tait.co.nz> wrote:

[#141339] Re: RCR 303: nil should accept missing methods and return nil — Hal Fulton <hal9000@...> 2005/05/06

Luke Graham wrote:

[#141345] Re: RCR 303: nil should accept missing methods and return nil — John Carter <john.carter@...> 2005/05/06

On Fri, 6 May 2005, Hal Fulton wrote:

[#141340] Prove me Wrong! Re: RCR 303: nil should accept missing methods — John Carter <john.carter@...> 2005/05/06

On Fri, 6 May 2005, Alexey Verkhovsky wrote:

[#141349] What sound does no duck make? — John Carter <john.carter@...>

Imagine a flock of ducks in the sky. Listen.

13 messages 2005/05/06

[#141368] Re: compiler error: argument of type "VALUE *" is incompatible with parameter of type "VALUE" — me2faster@...

On May 5, 2005, at 2:44 PM, me2faster@excite.com wrote:

10 messages 2005/05/06

[#141529] [NITRO] - Mr. George Moschovitis applies Censorship on Public Project Forum — Ilias Lazaridis <ilias@...>

To understand further the _real_ difference between Nitro/Og and

25 messages 2005/05/07

[#141530] [NITRO] - Mr. Moschovitis Revolutionary Redefinition of an Open Source Project — Ilias Lazaridis <ilias@...>

George Moschovitis wrote

15 messages 2005/05/07

[#141576] HighLine 0.4.0 — James Edward Gray II <james@...>

HighLine 0.4.0 Released

29 messages 2005/05/07
[#141616] Re: HighLine 0.4.0 — "Vincent Foley" <vfoley@...> 2005/05/07

Hello James,

[#141618] Re: HighLine 0.4.0 — James Edward Gray II <james@...> 2005/05/07

On May 7, 2005, at 4:19 PM, Vincent Foley wrote:

[#141598] Vacation - email me when Ilias is gone or people FINALLY stop responding to him — Ryan Davis <ryand-ruby@...>

The signal:noise ratio on this list is terrible. I'm taking a

12 messages 2005/05/07
[#141647] Re: Vacation - email me when I. is gone or people FINALLY stop responding to him — Bertram Scharpf <lists@...> 2005/05/08

Hi,

[#141615] - Sterile Classes / Sterile Meta Classes — Ilias Lazaridis <ilias@...>

Another suggestion for the "Ruby Singleton Classes" or "Exclusive Classes":

72 messages 2005/05/07
[#141681] Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes — Yukihiro Matsumoto <matz@...> 2005/05/08

In message "Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes"

[#141709] Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes — Carlos <angus@...> 2005/05/08

[Yukihiro Matsumoto <matz@ruby-lang.org>, 2005-05-08 17.13 CEST]

[#141710] Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes — Hal Fulton <hal9000@...> 2005/05/08

Carlos wrote:

[#141715] Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes — Yukihiro Matsumoto <matz@...> 2005/05/08

Hi,

[#141719] Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes — "David A. Black" <dblack@...> 2005/05/08

Hi --

[#141748] Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes — Yukihiro Matsumoto <matz@...> 2005/05/08

Hi,

[#141810] Re: [ETYMOLOGY] - Sterile Classes / Sterile Meta Classes — Yukihiro Matsumoto <matz@...> 2005/05/09

Hi,

[#141655] No Thing Here vs Uninitialized and RCR 303 — Cyent <cyent@...>

I'm observing a general trend in the responses to RCR 303.

26 messages 2005/05/08
[#141745] Re: No Thing Here vs Uninitialized and RCR 303 — Lionel Thiry <lthiryidontwantspam@...> 2005/05/08

Cyent a 馗rit :

[#141746] Re: No Thing Here vs Uninitialized and RCR 303 — Bill Atkins <batkins57@...> 2005/05/08

This isn't about changing programming habits. Having nil return nil

[#141707] Singleton class terminology — Hal Fulton <hal9000@...>

Just expressing my opinion here.

16 messages 2005/05/08

[#141776] Stats comp.lang.ruby (last 7 days) — Balwinder Singh Dheeman <bsd.SANSPAM@...>

Stats comp.lang.ruby (last 7 days)

15 messages 2005/05/09

[#141875] How to extract texts from html source? — "Sam Kong" <sam.s.kong@...>

Hi, all!

14 messages 2005/05/09

[#141900] Still umlauts — Bertram Scharpf <lists@...>

Hi,

8 messages 2005/05/09
[#142448] Re: Still umlauts — "Josef 'Jupp' SCHUGT" <jupp@...> 2005/05/12

Hi!

[#142507] Re: Still umlauts — Bertram Scharpf <lists@...> 2005/05/13

Hi,

[#142514] Re: Still umlauts — Jonas Hartmann <Mail@...> 2005/05/13

Bertram Scharpf wrote:

[#142527] Re: Still umlauts — =?WINDOWS-1252?Q?Brian_Schr=F6der?= <ruby.brian@...> 2005/05/13

On 13/05/05, Jonas Hartmann <Mail@jonas-hartmann.com> wrote:> Bertram Scharpf wrote:> > Hi,> >> > Am Freitag, 13. Mai 2005, 04:34:00 +0900 schrieb Josef 'Jupp' SCHUGT:> >> >>At Tue, 10 May 2005 06:58:30 +0900, Bertram Scharpf wrote:> >>> >>>does this no longer work?> >>> >>You forgot to define the meaning of 'no longer works':> >>> >> - What precisely do you mean by 'it works'?> >> >> > Sorry, that was not actually elaborate. Now I think it> > never worked at all.> >> >> >>>--------------------> >>>#!/usr/bin/env ruby> >>># -*- coding: UTF-8 -*-> >>>> >>>puts $KCODE> >>>puts "蔕ヨワ゜"> >>>--------------------> >>>> >>>I tried it with Ruby 1.8.2 and 1.9, Debian Linux.> >>>What do I miss?> >> >> > In the meantime I received an answer in ruby-core and it> > seems Matz just _planned_ to implement it but didn't have> > the time yet.> >> > The problem arises when my program is run on SuSE Linux> > where the default encoding is UTF-8.> >> > A better way to test in which encoding you reside is:> >> > "テ =~ /./> > puts $&.length> >> > This gives 1 in `None' and 2 in `UTF-8'.> >> >> >>When in doubt *set* $KCODE explicitly.> >> >> > This has no influence on how the source code is read. The> > string " produces an error when `ruby -Ku' is called.> >> > Of course I should have written "\xc3\xa4" and "\xc3".> > Is this the only way to handle strings UTF-8 in ruby?> > >> > Sorry again for the noise.> >> > Bertram> >> >> > regards> jonas> >

[#141958] Redesign 2005, Round Two — why the lucky stiff <ruby-talk@...>

I'm happy to say that our little redesign team has come to accord on a

80 messages 2005/05/10
[#142020] Re: [ANN] Redesign 2005, Round Two — gabriele renzi <surrender_it@...> 2005/05/10

why the lucky stiff ha scritto:

[#142033] Re: [ANN] Redesign 2005, Round Two — Ilias Lazaridis <ilias@...> 2005/05/10

why the lucky stiff wrote:

[#142041] Re: [ANN] Redesign 2005, Round Two — Mark Hubbart <discordantus@...> 2005/05/10

On 5/10/05, Ilias Lazaridis <ilias@lazaridis.com> wrote:

[#142057] Re: [ANN] Redesign 2005, Round Two — Nikolai Weibull <mailing-lists.ruby-talk@...> 2005/05/10

Mark Hubbart, May 11:

[#142196] Re: Redesign 2005, Round Two — "Karl von Laudermann" <doodpants@...> 2005/05/11

[#142219] Re: Redesign 2005, Round Two — "David A. Black" <dblack@...> 2005/05/11

Hi --

[#142221] Re: Redesign 2005, Round Two — James Britt <james_b@...> 2005/05/11

David A. Black wrote:

[#142237] Re: Redesign 2005, Round Two — "Ryan Leavengood" <mrcode@...> 2005/05/11

James Britt wrote:

[#142252] Re: Redesign 2005, Round Two — "David A. Black" <dblack@...> 2005/05/11

Hi --

[#142267] Re: Redesign 2005, Round Two — James Britt <james_b@...> 2005/05/11

David A. Black wrote:

[#142274] Re: Redesign 2005, Round Two — "John W. Long" <ng@...> 2005/05/11

James Britt wrote:

[#142302] Re: Redesign 2005, Round Two — Yukihiro Matsumoto <matz@...> 2005/05/12

[#142054] String Hashing Algorithms — "Phrogz" <gavin@...>

Summary

16 messages 2005/05/10

[#142129] options parsing: required and conflict — Kirill Shutemov <k.shutemov@...>

Can I define options dependencies using OptionParser?

13 messages 2005/05/11
[#142130] Re: options parsing: required and conflict — "Robert Klemme" <bob.news@...> 2005/05/11

Kirill Shutemov wrote:

[#142133] ruby vs. java? — "Franz Hartmann" <porschefranz@...>

Hello all,

61 messages 2005/05/11
[#142136] Re: ruby vs. java? — Michael Ulm <michael.ulm@...> 2005/05/11

Franz Hartmann wrote:

[#142141] Re: ruby vs. java? — "Franz Hartmann" <porschefranz@...> 2005/05/11

Hello Michael and all of you,

[#142149] Re: ruby vs. java? — Logan Capaldo <logancapaldo@...> 2005/05/11

On 5/11/05, Franz Hartmann <porschefranz@hotmail.com> wrote:

[#142155] Re: ruby vs. java? — "Franz Hartmann" <porschefranz@...> 2005/05/11

Hello Logan,

[#142166] Re: ruby vs. java? — Ralf Mler <r_mueller@...> 2005/05/11

[#142171] Re: ruby vs. java? — "Franz Hartmann" <porschefranz@...> 2005/05/11

Ralf,

[#142176] Re: ruby vs. java? — Ralf Mler <r_mueller@...> 2005/05/11

> (physician = Arzt, physicist = Physiker) :-)))

[#142224] alternatives to ? : contruct — "John-Mason P. Shackelford" <jpshack@...>

As an alternative to:

21 messages 2005/05/11

[#142260] Re: object loops and what they return — Eric Mahurin <eric_mahurin@...>

That sure looks ugly. I don't see any advantage of this over:

33 messages 2005/05/11
[#142359] Re: {} vs begin/end [was Re: object loops and what they return] — "Robert Klemme" <bob.news@...> 2005/05/12

Brian Schrer wrote:

[#142379] Re: {} vs begin/end [was Re: object loops and what they return] — "Jim Weirich" <jim@...> 2005/05/12

[#142268] Request for advice on applying a license — Nikolai Weibull <mailing-lists.ruby-talk@...>

Hi!

14 messages 2005/05/11
[#142276] Re: [OT] Request for advice on applying a license — Ben Giddings <bg-rubytalk@...> 2005/05/11

On Wednesday 11 May 2005 18:59, Nikolai Weibull wrote:

[#142370] Re: [OT] Request for advice on applying a license — Christian Neukirchen <chneukirchen@...> 2005/05/12

Ben Giddings <bg-rubytalk@infofiend.com> writes:

[#142342] Go through directories recursively — Jens Riedel <JensRie@...>

Hello,

17 messages 2005/05/12

[#142378] Amazing Mazes (#31) — Ruby Quiz <james@...>

Wow, these solutions are great fun to play with. I think next week's quiz needs

16 messages 2005/05/12

[#142404] We need a comprehensive test suite — Daniel Berger <djberge@...>

All,

12 messages 2005/05/12

[#142462] Get back data from a child (with exec) — Lawrence Oluyede <raims@...>

13 messages 2005/05/12

[#142620] ruby in WinXP as an automation tool — "kevin.gc@..." <kevin.gc@...>

Can anyone tell me if it can be done?

19 messages 2005/05/14

[#142671] infinite number of singleton_classes — Lionel Thiry <lthiryidontwantspam@...>

Hello!

37 messages 2005/05/15
[#142710] Re: infinite number of singleton_classes — Ara.T.Howard@... 2005/05/15

On Sun, 15 May 2005, Lionel Thiry wrote:

[#142745] Re: infinite number of singleton_classes — Lionel Thiry <lthiryidontwantspam@...> 2005/05/15

Ara.T.Howard@noaa.gov a 馗rit :

[#142746] Re: infinite number of singleton_classes — Hal Fulton <hal9000@...> 2005/05/15

Lionel Thiry wrote:

[#142711] Re: infinite number of singleton_classes — "David A. Black" <dblack@...> 2005/05/15

Hi --

[#142806] IRB, Mac OS X, command-line require via "-r" and Bus Errors — "James Adam" <james.adam@...>

Hey All,

22 messages 2005/05/16

[#142808] Ruby Weekly News 2nd - 15th May 2005 — timsuth@... (Tim Sutherland)

http://www.rubyweeklynews.org/20050515.html

15 messages 2005/05/16
[#143444] Array.=== Bug, Rails Bug, or brain failure? — Markus <markus@...> 2005/05/23

I've got some rails code that is failing in a very strange way. It is

[#143447] Re: Array.=== Bug, Rails Bug, or brain failure? — Jamis Buck <jamis@37signals.com> 2005/05/23

Markus,

[#143449] Re: Array.=== Bug, Rails Bug, or brain failure? — Markus <markus@...> 2005/05/23

[#142894] Google API, Soap and windows XP — ruby talk <rubytalk@...>

Hello,I am playing with the google api and soap. I have the newest versionof soap and i think ruby 1.8. I created my code on a laptop withmandrake 10.2 with the same version of ruby and soap. On my laptop itworks fine. On my windows computer it give me an error."F:\Documents and Settings\iv\Desktop\googlerip>ruby googled.rbmonkey filetype:pdfLoading compatibility library...c:/ruby/lib/ruby/1.8/xsd/datatypes.rb:172:in `_set': {http://www.w3.org/2001/XMLSchema}string: cannot accept '<b>...</b> Tibetan year of the <b>monkey</b>. These instructions are traditionally given <b>...</b><br> thus will give the rare ΓÇÖ<b>Monkey</b>-Year-TeachingsΓÇÖ after the inauguration in <b>...</b>'. (XSD::ValueSpaceError) from c:/ruby/lib/ruby/1.8/xsd/datatypes.rb:114:in `set' from c:/ruby/lib/ruby/1.8/soap/encodingstyle/soapHandler.rb:453:in `decode_textbuf' from c:/ruby/lib/ruby/1.8/soap/encodingstyle/soapHandler.rb:214:in `decode_tag_end' from c:/ruby/lib/ruby/1.8/soap/parser.rb:185:in `decode_tag_end' from c:/ruby/lib/ruby/1.8/soap/parser.rb:146:in `end_element' from c:/ruby/lib/ruby/1.8/xsd/xmlparser/parser.rb:75:in `end_element' from c:/ruby/lib/ruby/1.8/xsd/xmlparser/xmlparser.rb:36:in `do_parse' from c:/ruby/lib/ruby/1.8/xsd/xmlparser/xmlparser.rb:31:in `parse' ... 7 levels... from (eval):2:in `doGoogleSearch' from googled.rb:16 from googled.rb:15:in `each' from googled.rb:15"

2 messages 2005/05/17

[#142901] Help regarding def wrapper — Nikolai Weibull <mailing-lists.ruby-talk@...>

I窶囘 like to have a def that I can scope in one go, i.e.,

17 messages 2005/05/17

[#143041] Compiling MySQL-Ruby on Tiger — "pat allan" <pat.allan@...>

Hi all

21 messages 2005/05/18

[#143087] (newbie Q) opposite of inspect for strings — "Basile Starynkevitch [news]" <basile-news@...>

14 messages 2005/05/18

[#143225] Re: Multiple return and parallel assignement — Eric Mahurin <eric_mahurin@...>

25 messages 2005/05/20

[#143229] Web services and Ruby — Luke Kanies <luke@...>

Hi all,

17 messages 2005/05/20

[#143252] HighLine 0.6.0 -- Now with menus! — James Edward Gray II <james@...>

HighLine 0.6.0 Released

18 messages 2005/05/20

[#143305] join not in Enumerable — Logan Capaldo <logancapaldo@...>

Just a few minutes ago I was playing with irb as I am wont to do, and

14 messages 2005/05/21

[#143328] Vim's Ruby indenting — "Vincent Foley" <vfoley@...>

Hi to all the vim users,

17 messages 2005/05/22

[#143337] Uniform vector class, inheriting from Array: How to make sure that methods return a Vector and not an Array? — Thomas <sanobast-2005a@...>

Hi folks,

8 messages 2005/05/22
[#143342] Re: Uniform vector class, inheriting from Array: How to make sure that methods return a Vector and not an Array? — Brian Schrer <ruby.brian@...> 2005/05/22

On 22/05/05, Thomas <sanobast-2005a@yahoo.de> wrote:

[#143366] Stats comp.lang.ruby (last 7 days) — Balwinder Singh Dheeman <bsd.SANSPAM@...>

Stats comp.lang.ruby (last 7 days)

11 messages 2005/05/23

[#143375] sciTe editor IRB window getting double characters — "soxinbox" <faker@...>

Has any one had a problem with the latest release of Ruby and the included

10 messages 2005/05/23

[#143515] if __FILE_ == $0 executed twice — Han Holl <han.holl@...>

Hello,

21 messages 2005/05/24

[#143550] new article — pat eyler <pat.eyler@...>

Sorry for posting about my own article, but I'm interested in feedback,

24 messages 2005/05/24

[#143655] A different perspective on Ruby. — ES <ruby-ml@...>

47 messages 2005/05/26
[#143681] Re: A different perspective on Ruby. — "gsinclair@..." <gsinclair@...> 2005/05/26

ES wrote:

[#143683] Re: A different perspective on Ruby. — Brian Schrer <ruby.brian@...> 2005/05/26

On 26/05/05, gsinclair@gmail.com <gsinclair@gmail.com> wrote:

[#143705] Intellisense and the psychology of typing — andrew.queisser@...

Yesterday I typed in some C++ code that called a function with two

50 messages 2005/05/26
[#143710] Re: Intellisense and the psychology of typing — Thomas Adam <thomas@...> 2005/05/26

On Fri, May 27, 2005 at 01:35:19AM +0900, andrew.queisser@hp.com wrote:

[#143716] Re: Intellisense and the psychology of typing — Lothar Scholz <mailinglists@...> 2005/05/26

Hello Thomas,

[#144032] Re: Intellisense and the psychology of typing — Richard Cole <rcole@...> 2005/05/30

Lothar Scholz wrote:

[#144040] Re: Intellisense and the psychology of typing — Austin Ziegler <halostatue@...> 2005/05/30

On 5/30/05, Richard Cole <rcole@itee.uq.edu.au> wrote:

[#144080] Re: Intellisense and the psychology of typing — Lothar Scholz <mailinglists@...> 2005/05/31

Hello Austin,

[#144088] Re: Intellisense and the psychology of typing — Austin Ziegler <halostatue@...> 2005/05/31

On 5/31/05, Lothar Scholz <mailinglists@scriptolutions.com> wrote:

[#144109] Re: Intellisense and the psychology of typing — Caleb Clausen <vikkous@...> 2005/05/31

Austin Ziegler wrote:

[#144114] Re: Intellisense and the psychology of typing — Austin Ziegler <halostatue@...> 2005/05/31

On 5/31/05, Caleb Clausen <vikkous@gmail.com> wrote:

[#144124] Re: Intellisense and the psychology of typing — Eric Mahurin <eric_mahurin@...> 2005/05/31

--- Austin Ziegler <halostatue@gmail.com> wrote:

[#143799] Plz comment — Dr Balwinder S Dheeman <bsd.SANSPAM@...>

Dear Rubiest!

22 messages 2005/05/27

[#143812] Ruby on Rails interest in comp.lang.python — Stephen Kellett <snail@...>

A heads up to the Rails folks.

14 messages 2005/05/27

[#143825] How to build an index of phrases in a phrase/sentence? — Dan Fitzpatrick <dan@...>

I am trying to build an indexing structure on some phrases. Most phrases

11 messages 2005/05/27

[#143884] preventing Object#send from dispatching to a global method? — Francis Hwang <sera@...>

Is there a way to prevent Object#send from dispatching to a global

17 messages 2005/05/28
[#143908] Re: preventing Object#send from dispatching to a global method? — Jim Weirich <jim@...> 2005/05/29

[#143975] Ruby-VTK-0.2.0 was released — Seiya Nishizawa <seiya@...>

Hi everyone,

11 messages 2005/05/30

[#143976] Stats comp.lang.ruby (last 7 days) — Balwinder Singh Dheeman <bsd.SANSPAM@...>

Stats comp.lang.ruby (last 7 days)

26 messages 2005/05/30
[#144084] Re: Stats comp.lang.ruby (last 7 days) — "David A. Black" <dblack@...> 2005/05/31

On Mon, 30 May 2005, Balwinder Singh Dheeman wrote:

[#144107] Re: Stats comp.lang.ruby (last 7 days) — pat eyler <pat.eyler@...> 2005/05/31

On 5/31/05, David A. Black <dblack@wobblini.net> wrote:

[#144113] Re: Stats comp.lang.ruby (last 7 days) — James Britt <james_b@...> 2005/05/31

pat eyler wrote:

[#144144] Re: Stats comp.lang.ruby (last 7 days) — Dr Balwinder S Dheeman <bsd.SANSPAM@...> 2005/05/31

On 05/31/2005 11:44 PM, James Britt wrote:

[#144145] Re: Stats comp.lang.ruby (last 7 days) — James Edward Gray II <james@...> 2005/05/31

On May 31, 2005, at 6:15 PM, Dr Balwinder S Dheeman wrote:

[#144004] creating variable with eval — "Geert Fannes" <Geert.Fannes@...>

Hello, what is the scope of a variable created inside an eval()

14 messages 2005/05/30

[#144096] parseargs-0.0.0 — "Ara.T.Howard" <Ara.T.Howard@...>

23 messages 2005/05/31
[#144170] binding, ObjectSpace._id2ref [WAS] Re: [ANN] parseargs-0.0.0 — "Zev Blut" <rubyzbibd@...> 2005/06/01

Hello,

[#144254] Re: binding, ObjectSpace._id2ref [WAS] Re: [ANN] parseargs-0.0.0 — "Ara.T.Howard" <Ara.T.Howard@...> 2005/06/01

On Wed, 1 Jun 2005, Zev Blut wrote:

[#144306] Re: binding, ObjectSpace._id2ref [WAS] Re: [ANN] parseargs-0.0.0 — "Zev Blut" <rubyzbibd@...> 2005/06/02

Hello,

[SUMMARY] Amazing Mazes (#31)

From: Ruby Quiz <james@...>
Date: 2005-05-12 14:30:37 UTC
List: ruby-talk #142378
Wow, these solutions are great fun to play with.  I think next week's quiz needs
to give me a little man icon and some controls!  Throw in some doors, some keys,
and little critters to chase me around and there's simply no chance at all I
would get a summary written next week.  Hmm, maybe it's not such a good idea.

Jokes aside, do run the solutions a few times each this week.  It's fun to see
what they build.  Then peek inside the code and read the comments.  Good stuff
in there.

Below, I want to look into Dominik Bathon's code.  It is a nice search and
lightning quick!  On my machine, it makes and solves quizzes faster than the
other solutions can just make them.  Even better, it uses a complex internal
representation (mainly for speed), yet still comes out with clean algorithms.  I
was quite impressed by that.

Let's get to the code.  Dominik starts off by defining a helper method in Hash:

	class Hash
	      # find the key for with the smallest value, delete it and return it
	      def delete_min_value
	            return nil if empty?
	            minkey=min=nil
	            each { |k, v|
	                  min, minkey=v, k if !min || v<min
	            }
	            delete(minkey)
	            minkey
	      end
	end
	
	# ...

The comment pretty much explains what's going on there.  Each pair of the Hash
is compared by value.  The pair with the lowest value is deleted and the key for
that value is returned.

On to the interesting parts.  Here's the start of the main class used by the
solution:

	# Maze represents the maze ;-)
	#
	# Cells/positions in the maze are represented by Numbers
	# (from 0 to w*h-1), each position corresponds to x/y coordinates,
	# you can convert between positions and coordinates by coord2pos
	# and pos2coord.
	#
	# The walls for each position are stored in the String @data. The walls
	# for position p are stored in the first two bits of @data[p], the
	# other bits are unused. If bit one is set then p has a north wall, if
	# bit two is set then p has a west wall.
	#
	# Maze#generate generates a (random) maze using the method described at
	# http://www.mazeworks.com/mazegen/mazetut/
	#
	# Maze#shortest_path uses Dijkstra's shortest path algorithm, so it can
	# not anly find shortest pathes in perfect mazes, but also in mazes
	# where different pathes between two position exist.

	class Maze
	      attr_reader :w, :h # width, height

	      def initialize(w, h)
	            @w, @h=[w, 1].max, [h, 1].max
	            @wh=@w*@h
	            @neighbors_cache={}
	            set_all_walls
	      end
	
	      # ...

I know that section is mostly a comment, but you'll want to read through it. 
It's interesting information and it introduces you to the internal format the
code uses.

After that, we see some readers defined and some simple initialization work. 
Set a width and height, ensuring they are both at least 1.  Nice use of max()
there.  Calculate width times height or the total number of cells, initialize a
cache and call set_all_walls().

That means we need some more code:

	      # ...
	
	      def set_all_walls
	            # set all bits
	            @data=3.chr * (@wh)
	            nil
	      end
	      def clear_all_walls
	            # all except outer border
	            @data=0.chr * (@wh)
	            # set north walls of row 0
	            w.times { |i| @data[i] |= 1 }
	            # set west walls of col 0
	            h.times { |i| @data[i*w] |= 2 }
	            nil
	      end

	      # ...

Okay, now we start to get tricky.  Remember the initial comment about using bits
for the walls.  We're only tracking two walls here, north and west.  Of course
cells can still have up to four walls, but your east wall is just your
neighbor's west wall and your south wall is the north wall for the cell below
you.

Now, what do you get if you turn two bits on?  3.  The set_all_walls() method
just translates that to a character and duplicates it for every cell.  That
gives us a String representing the entire maze with all the walls turned on.

That should make clear_all_walls() more obvious.  This time we want no walls so
we don't set any bits.  Translate 0 to a character and duplicate.  However, we
still need the edges of the maze.  All cells in the top row need a north wall
(set the 1 bit).  Then all the cells in the first column need a west wall (set
the 2 bit).  That makes up the rest of the method.

Ready for the next chunk?

	      # ...

	      # positions in path will be printed as "X"
	      def to_s(path=[])
	            ph={}
	            path.each { |i| ph[i]=true }
	            res=""
	            h.times { |y|
	                  w.times { |x|
	                        res << "+" << ( (@data[y*w+x] & 1 > 0) ? "---" :
	                                                                 "   " )
	                  }
	                  res << "+\n"
	                  w.times { |x|
	                        res << ((@data[y*w+x] & 2 > 0) ? "|" : " ")
	                        res << (ph[y*w+x] ? " X " : "   ")
	                  }
	                  res << "|\n"
	            }
	            res << ("+---"*w) << "+"
	      end
	      def inspect
	            "#<#{self.class.name} #{w}x#{h}>"
	      end

	      # ...

The to_s() method draws mazes.  The first two lines fill a Hash with the
solution path, if one is given.  The Hash is indexed identically as the maze
String and values can be true (if it's on the path) or the default nil, (when
it's not).

The rest of that method does the drawing.  It walks row by row with h.times(),
down the maze drawing cells.  The first w.times() call handles the north walls. 
First it adds a "+", then it adds "---" if the 1 bit is set or "   " if it's 
not.  Next we need another "+" and a "\n".  Now the second w.times() block
handles the west wall and path.  First it checks to see if the 2 bit is set for
the current cell, outputting "|" if it is and " " if it's not.  Then the path is
checked.  If this cell is on the path, it's filled with " X " and if it's not,
the code adds a "   ".

The last two lines of the method are important.  They ensure a final "|" is
always added to the end of a row and a final "+---" is placed at the end each
column of the maze.  This handles the east and south borders of the maze, which
are not covered by the bits.

The other method, inspect(), just returns a class name, width and height.

	      # ...
	      
	      # maze positions are cell indices from 0 to w*h-1
	      # the following functions do conversions to and from coordinates
	      def coord2pos(x, y)
	            (y % h)*w+(x % w)
	      end
	      def pos2coord(p)
	            [p % w, (p/w) % h]
	      end

	      # ...

These convertors were explained in the initial comment and they are explained
again here.  No surprises there.

	      # returns valid neighbors to p, doesn't care about walls
	      def neighbors(p)
	            if ce=@neighbors_cache[p]; return ce; end
	            res=[p-w, p+w]
	            res << p-1 if p%w > 0
	            res << p+1 if p%w < w-1
	            @neighbors_cache[p] = res.find_all { |t| t>=0 && t<@wh }
	      end

This returns the indices of the up to four neighboring cells.  It caches this
lookup the first time it does it, since it will never change.  The first line
just uses the cache if it has already been figured.  The second line adds the
cell above and the cell below.  Note that these numbers are found by simple math
and could be outside the bounds of the maze.  The next two lines add the left
and right cells.  We're more careful with our math here, because a wrong answer
could look right:  The last cell of the first row is "left" of the first cell of
the second row, in our one dimensional String that holds the maze data.  The
final line, stores the indices to the cache and returns them, after using
find_all() to eliminate any bogus number that crept in.

	      # ...
      
	      def wall_between?(p1, p2)
	            p1, p2=[p1, p2].sort
	            if p2-p1==w # check north wall of p2
	                  @data[p2] & 1 > 0
	            elsif p2-p1==1 # check west wall of p2
	                  @data[p2] & 2 > 0
	            else
	                  false
	            end
	      end
	      def set_wall(p1, p2)
	            p1, p2=[p1, p2].sort
	            if p2-p1==w # set north wall of p2
	                  @data[p2] |= 1
	            elsif p2-p1==1 # set west wall of p2
	                  @data[p2] |= 2
	            end
	            nil
	      end
	      def unset_wall(p1, p2)
	            p1, p2=[p1, p2].sort
	            if p2-p1==w # unset north wall of p2
	                  @data[p2] &= ~1
	            elsif p2-p1==1 # unset west wall of p2
	                  @data[p2] &= ~2
	            end
	            nil
	      end
      
	      # ...

These three methods are all very similar.  Given two cells, the first checks if
there is a wall between them, the second sets the wall between them, and the
third unsets it.  The if's just figure out if we are talking about a north wall
or a west wall.  The rest is bit testing or setting.

On to maze generation:

	      # ...
	
	      # generate a (random) perfect maze
	      def generate(random=true)
	            set_all_walls
	            # (random) depth first search method
	            visited={0 => true}
	            stack=[0]
	            until stack.empty?
	                  n=neighbors(stack.last).reject { |p| visited[p] }
	                  if n.empty?
	                        stack.pop
	                  else
	                        # choose one unvisited neighbor
	                        np=n[random ? rand(n.size) : 0]
	                        unset_wall(stack.last, np)
	                        visited[np]=true
	                        # if all neighbors are visited then here is
	                        # nothing left to do
	                        stack.pop if n.size==1
	                        stack.push np
	                  end
	            end
	            self
	      end

	      # ...

This algorithm came out very clean, I think.  Not a bit operation in sight. 
First it turns all the walls on.  Then it sets up an Array for tracking visited
cells and another as a stack to drive the process.  While there is something on
the stack, the code looks at each not-yet-visited neighbor.  If there are no
neighbors in that set, the stack is popped and the routine moves on.  However,
if there are, one is chosen at random and the wall is knocked out between them. 
If that neighbor was the last unvisited one for this cell, the code pops the
current cell off the stack.  The neighbor cell is set to visited and pushed onto
the stack, moving the build process to that location for the next iteration.

That covers creation.  Now we need a solver:

	      # ...
	
	      # central part of Dijkstra's shortest path algorithm:
	      # returns a hash that associates each reachable (from start)
	      # position p, with the previous position on the shortest path
	      # from start to p and the length of that path.
	      # example: if the shortest path from 0 to 2 is [0, 1, 2], then
	      # prev[2]==[1, 2], prev[1]==[0, 1] and prev[0]==[nil, 0].
	      # so you can get all shortest paths from start to each reachable
	      # position out of the returned hash.
	      # if stop_at!=nil the method stops when the previous cell on the
	      # shortest path from start to stop_at is found.
	      def build_prev_hash(start, stop_at=nil)
	            prev={start=>[nil, 0]} # hash to be returned
	            return prev if stop_at==start
	            # positions which we have seen, but we are not yet sure about
	            # the shortest path to them (the value is length of the path,
	            # for delete_min_value):
	            active={start=>0}
	            until active.empty?
	                  # get the position with the shortest path from the
	                  # active list
	                  cur=active.delete_min_value
	                  return prev if cur==stop_at
	                  newlength=prev[cur][1]+1 # path to cur length + 1
	                  # for all reachable neighbors of cur, check if we found
	                  # a shorter path to them
	                  neighbors(cur).each { |n|
	                        # ignore unreachable
	                        next if wall_between?(cur, n)
	                        if old=prev[n] # was n already visited
	                              # if we found a longer path, ignore it
	                              next if newlength>=old[1]
	                        end
	                        # (re)add new position to active list
	                        active[n]=newlength
	                        # set new prev and length
	                        prev[n]=[cur, newlength]
	                  }
	            end
	            prev
	      end

	      # ...

I really don't think I need to launch into too deep an explanation here as the
comments guide you right through it.  The short story is that this method
branches out from a starting cell, walking to each neighbor and always counting
its steps.  While doing this, it is building the Hash described in the first
comment, which points to the cell that came before on the shortest path.  Using
that Hash, returned by this method, you can easily construct the shortest path
to any cell the algorithm visited.  Handy stuff!  Let's see how it gets put to
use:

	      # ...
      
	      def shortest_path(from, to)
	            prev=build_prev_hash(from, to)
	            if prev[to]
	                  # path found, build it by following the prev hash from
	                  # "to" to "from"
	                  path=[to]
	                  path.unshift(to) while to=prev[to][0]
	                  path
	            else
	                  nil
	            end
	      end
      
	      # ...

Given a starting and ending cell, this returns just what the name implies.  It
builds the magic Hash we just looked at on the first line, then just walks the
path in reverse until it reaches the start (nil in the Hash).  Again, clean and
simple.  Nice coding Dominik.

Let's look at the other search the code provides:

	      # ...

	      # finds the longest shortest path in this maze, only works if
	      # there is at least one position that can only reach one
	      # neighbor, because we search only starting at those positions.
	      def longest_shortest_path
	            startp=endp=nil
	            max=-1
	            @wh.times { |p|
	                  # if current p can only reach 1 neighbor
	                  if neighbors(p).reject { |n|
	                           wall_between?(p, n)
	                     }.size==1
	                        prev=build_prev_hash(p)
	                        # search longest path from p
	                        tend, tmax=nil, -1
	                        prev.each { |k, v|
	                              if v[1]>tmax
	                                    tend=k
	                                    tmax=v[1]
	                              end
	                        }
	                        if tmax>max
	                              max=tmax
	                              startp, endp=p, tend
	                        end
	                  end
	            }
	            if startp # path found
	                  shortest_path(startp, endp)
	            else
	                  nil
	            end
	      end
	end

	# ...

This method walks the maze, looking for cells that are dead-ends.  From each of
those, it builds the path Hash and checks the lengths of each path found.  In
the end, it will return the longest path it saw.

Just a little more code is needed for human interface:

	# ...

	if $0 == __FILE__
	      ARGV.shift if search_longest=ARGV[0]=="-l"
	      w, h, from, to=ARGV
	      m=Maze.new(w.to_i, h.to_i)
	      m.generate
	      puts "Maze:", m.to_s
	      if from=~/(\d+),(\d+)/
	            p1=m.coord2pos($1.to_i, $2.to_i)
	      else
	            p1=rand(m.w*m.h)
	      end
	      if to=~/(\d+),(\d+)/
	            p2=m.coord2pos($1.to_i, $2.to_i)
	      else
	            p2=rand(m.w*m.h)
	      end

	      path=m.shortest_path(p1, p2)
	      puts "\nShortest path from #{m.pos2coord(p1).inspect} to " \
	      "#{m.pos2coord(p2).inspect}:", m.to_s(path)

	      if search_longest
	            path=m.longest_shortest_path
	            puts "\nLongest shortest path (from " \
	            "#{m.pos2coord(path[0]).inspect} to " \
	            "#{m.pos2coord(path[-1]).inspect}:",
	            m.to_s(path)
	      end
	end

This is just option parsing and display.  The code checks for a special first
"-l" option, which just sets a flag to add the long search.

The next chunk reads a width and height then builds and displays a maze of the
indicated size.   The code next reads from and to cells for a solution search,
if they where provided.  Random coordinates are used when from or to cells are
absent.  Note the use of the coord2pos() convertor in here.

Finally, the shortest path is displayed.  The longer search is also added, if
requested.  Dominik uses an unusual Ruby idiom here, "string" "string".  Ruby
will concatenate these, even without the + between them.  (I didn't know this!) 
However, the rumor is that this feature may vanish in a future version of Ruby,
so it's probably not a good habit to get into.

My thanks to those who braved the mazes this week.  Really interesting (and
fun!) solutions were given by all.

Tomorrow's quiz is a little client and server fun, care of Pat Eyler's
children...

In This Thread

Prev Next