[#253828] Getting the last N bytes of a string: — Brian Candler <B.Candler@...>

What's the simplest way to get only the last 10 bytes of a string?

21 messages 2007/06/01

[#253837] FizzBuzz (#126) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

177 messages 2007/06/01
[#253853] Re: [QUIZ] FizzBuzz (#126) — Hans Fugal <fugalh@...> 2007/06/01

Ruby Quiz wrote:

[#253854] Re: FizzBuzz (#126) — Paul Novak <novakps@...> 2007/06/01

On Jun 1, 9:51 am, Hans Fugal <fug...@zianet.com> wrote:

[#253885] Re: [QUIZ] FizzBuzz (#126) — Daniel Martin <martin@...> 2007/06/01

Hans Fugal <fugalh@zianet.com> writes:

[#253945] Re: [QUIZ] FizzBuzz (#126) — Morton Goldberg <m_goldberg@...> 2007/06/02

On Jun 1, 2007, at 8:28 AM, Ruby Quiz wrote:

[#254215] Re: [QUIZ] FizzBuzz (#126) — James Edward Gray II <james@...> 2007/06/04

On Jun 1, 2007, at 10:37 PM, Morton Goldberg wrote:

[#253969] Re: [QUIZ] FizzBuzz (#126) — Daniel Martin <martin@...> 2007/06/02

Ruby Quiz <james@grayproductions.net> writes:

[#254095] Re: [QUIZ] FizzBuzz (#126) — Michael Glaesemann <grzm@...> 2007/06/03

My first Ruby Quiz submission.

[#254096] Re: FizzBuzz (#126) — Joshua Ballanco <jballanc@...> 2007/06/03

So, I've got to lay claim to the 56 byte solution:

[#254097] Re: FizzBuzz (#126) — "Robert Dober" <robert.dober@...> 2007/06/03

On 6/3/07, Joshua Ballanco <jballanc@gmail.com> wrote:

[#254104] Re: FizzBuzz (#126) — Joshua Ballanco <jballanc@...> 2007/06/03

Robert Dober wrote:

[#253838] nested methods don't really exist?! — Artur Merke <am@...>

Hi,

28 messages 2007/06/01
[#253906] Re: nested methods don't really exist?! — Robert Klemme <shortcutter@...> 2007/06/01

On 01.06.2007 14:36, Artur Merke wrote:

[#253919] Re: nested methods don't really exist?! — Trans <transfire@...> 2007/06/01

[#253961] Re: nested methods don't really exist?! — Robert Klemme <shortcutter@...> 2007/06/02

On 01.06.2007 23:14, Trans wrote:

[#253967] Re: nested methods don't really exist?! — "Robert Dober" <robert.dober@...> 2007/06/02

On 6/2/07, Robert Klemme <shortcutter@googlemail.com> wrote:

[#253893] Help with emailing attachments with Ruby... — grooveska <ryangs@...>

I am working on a script that will send an email with a .csv file

11 messages 2007/06/01

[#254054] No way of looking for a regrexp match starting from a particular point in a string? — Kenneth McDonald <kenneth.m.mcdonald@...>

I'm probably just missing something obvious, but I haven't found a way

26 messages 2007/06/03
[#254056] Re: No way of looking for a regrexp match starting from a particular point in a string? — Nobuyoshi Nakada <nobu@...> 2007/06/03

Hi,

[#254059] Re: No way of looking for a regrexp match starting from a particular point in a string? — "Patrick Hurley" <phurley@...> 2007/06/03

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

[#254063] Re: No way of looking for a regrexp match starting from a particular point in a string? — Nobuyoshi Nakada <nobu@...> 2007/06/03

Hi,

[#254235] Re: No way of looking for a regrexp match starting from a particular point in a string? — "Robert Dober" <robert.dober@...> 2007/06/04

On 6/3/07, Kenneth McDonald <kenneth.m.mcdonald@sbcglobal.net> wrote:

[#254132] FizzBuzz (#126) — "Christian Roese" <croese@...>

Great quiz, really got me thinking about other ways to solve this

16 messages 2007/06/03
[#254277] Re: [QUIZ] FizzBuzz (#126) — "Mike Moore" <blowmage@...> 2007/06/04

I didn't spend any time golfing this quiz, so I don't have anything crazy to

[#254217] code problems — "david karapetyan" <dkarapetyan@...>

why is the following code not valid

18 messages 2007/06/04
[#254218] Re: code problems — Nobuyoshi Nakada <nobu@...> 2007/06/04

Hi,

[#254219] Re: code problems — "david karapetyan" <dkarapetyan@...> 2007/06/04

thanks. i didn't realize i had to provide the block as well when i was

[#254223] Re: code problems — Nobuyoshi Nakada <nobu@...> 2007/06/04

Hi,

[#254291] Re: code problems — fREW <frioux@...> 2007/06/04

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

[#254250] Deleting a file - is there a less clumsy way to do this? — "Ronald Fischer" <ronald.fischer@...>

In my application, I often have blocks of code, where during preparation

13 messages 2007/06/04

[#254332] Reverse-range alternatives? — Kenneth McDonald <kenneth.m.mcdonald@...>

Since a reverse range (eg. 4...1) is functionally almost the same as an

11 messages 2007/06/04

[#254452] David Black's book _Ruby for Rails — finetan@...

Hi all

16 messages 2007/06/05

[#254459] [QUIZ] FizzBuzz (#126) [solution #1] — MenTaLguY <mental@...>

I've got two solutions this go-round. First, the solution I would present were I asked to do this in an actual job interview:

13 messages 2007/06/05

[#254467] Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...>

Hello, I'm working on Gecode/R, a Ruby interface to Gecode[0], allowing

24 messages 2007/06/05
[#254477] Re: Gecode/R - Request for syntax feedback — James Edward Gray II <james@...> 2007/06/05

On Jun 5, 2007, at 2:43 PM, Andreas Launila wrote:

[#254526] Re: Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...> 2007/06/06

James Edward Gray II wrote:

[#254544] Re: Gecode/R - Request for syntax feedback — James Edward Gray II <james@...> 2007/06/06

On Jun 6, 2007, at 5:21 AM, Andreas Launila wrote:

[#254561] Re: Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...> 2007/06/06

James Edward Gray II wrote:

[#254583] Re: Gecode/R - Request for syntax feedback — Andreas Launila <ruby-talk@...> 2007/06/06

Andreas Launila wrote:

[#254639] Globals not incrementing inside block — "Todd A. Jacobs" <tjacobs-sndr-019fdb@...>

I have the following snippet:

13 messages 2007/06/07
[#254642] Re: Globals not incrementing inside block — "Harry Kakueki" <list.push@...> 2007/06/07

On 6/7/07, Todd A. Jacobs <tjacobs-sndr-019fdb@codegnome.org> wrote:

[#254661] Mutually-Recursive Functions — Revence Kalibwani <revence27@...>

Ruby doesn't seem to do mutually-recursive functions. Or is it some

15 messages 2007/06/07
[#254664] Re: Mutually-Recursive Functions — Dan Zwell <dzwell@...> 2007/06/07

Revence Kalibwani wrote:

[#254665] Re: Mutually-Recursive Functions — Revence Kalibwani <revence27@...> 2007/06/07

Dan Zwell wrote:

[#254673] What about a 'series' type? — Peter Marsh <evil_grunger@...>

I'm sure everyone is fimilar with ranges:

17 messages 2007/06/07
[#254685] Re: What about a 'series' type? — seebs@... (Peter Seebach) 2007/06/07

In message <cd08f63ca2ad51e567d4288410f593da@ruby-forum.com>, Peter Marsh writes:

[#254686] Re: What about a 'series' type? — SonOfLilit <sonoflilit@...> 2007/06/07

Actually, the syntax:

[#254717] Problem with getting info from several websites — "Tom Bombadil" <bombadil.tom@...>

Hi there,

14 messages 2007/06/07
[#254741] Re: Problem with getting info from several websites — George Malamidis <george@...> 2007/06/07

Hi,

[#254799] Re: Problem with getting info from several websites — "Tom Bombadil" <bombadil.tom@...> 2007/06/08

George,

[#254743] Installing Curb Was: Re: ruby libcurl maintainer? — "Jano Svitok" <jan.svitok@...>

On 6/7/07, Md.elme focruzzaman Shuvo <shuvo.razi@gmail.com> wrote:

11 messages 2007/06/07
[#254816] Installing Curb Was: Re: ruby libcurl maintainer? — "Md.elme focruzzaman Shuvo" <shuvo.razi@...> 2007/06/08

Jano Svitok wrote:

[#254808] newbie question about Ri — Grehom <grehom@...>

I just installed the latest Windows version from Activestate (having

13 messages 2007/06/08

[#254812] practical ruby console on windows? — =?iso-8859-2?q?Kiripolszky_K=E1roly?= <karoly.kiripolszky@...>

Ehlo,

5 messages 2007/06/08

[#254831] Mexican Blanket (#127) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

16 messages 2007/06/08

[#254863] Synchronized attr_accessor — Nasir Khan <rubylearner@...>

I have a fairly repetitive use case of having to define attributes and

23 messages 2007/06/08
[#254865] Re: Synchronized attr_accessor — MenTaLguY <mental@...> 2007/06/08

On Sat, 9 Jun 2007 04:34:42 +0900, Nasir Khan <rubylearner@gmail.com> wrote:

[#254867] Re: Synchronized attr_accessor — Nasir Khan <rubylearner@...> 2007/06/08

This is about having a instance variable always accessed under a lock,

[#254879] Re: Synchronized attr_accessor — MenTaLguY <mental@...> 2007/06/08

On Sat, 9 Jun 2007 04:55:24 +0900, Nasir Khan <rubylearner@gmail.com> wrote:

[#254886] Re: Synchronized attr_accessor — Nasir Khan <rubylearner@...> 2007/06/08

There is no big picture.

[#254890] Re: Synchronized attr_accessor — MenTaLguY <mental@...> 2007/06/08

On Sat, 9 Jun 2007 06:54:04 +0900, Nasir Khan <rubylearner@gmail.com> wrote:

[#254900] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/09

Yeah I see what you guys mean...I was a little delusional. Now I

[#254915] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/09

Actually facets/more/synchash.rb does what I was looking for hash.

[#254943] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/09

Prodding it further I could come up with a method synchronizer.

[#255049] Re: Synchronized attr_accessor — "Caleb Clausen" <vikkous@...> 2007/06/10

Nasir Khan wrote:

[#255073] Re: Synchronized attr_accessor — "Nasir Khan" <rubylearner@...> 2007/06/11

Thanks for the feedback. Here is a refinement -

[#255093] Re: Synchronized attr_accessor — "Caleb Clausen" <vikkous@...> 2007/06/11

On 6/10/07, Nasir Khan <rubylearner@gmail.com> wrote:

[#254864] trouble running ruby programs — Hydro_Flame XZ18 <hydroflame@...>

I'm a newbie programmer and I just downloaded ruby today. I must say I'm

14 messages 2007/06/08
[#254866] Re: trouble running ruby programs — Peter Szinek <peter@...> 2007/06/08

> Can anyone help? I'm running Windows XP if that helps at all.

[#254870] Re: trouble running ruby programs — Jacob Gillie <hydroflame@...> 2007/06/08

I tried going to the command prompt, making sure the file was in the

[#254871] Re: trouble running ruby programs — "Michael W. Ryder" <_mwryder@...> 2007/06/08

Jacob Gillie wrote:

[#254917] Ruby wildcard command line argument auto expansion — Michael Jia <z_jia@...>

I want to pass in wildcard file names, and use it to match file names

14 messages 2007/06/09

[#254974] Passing block to Proc#call — "Erwin Abbott" <erwin.abbott@...>

I'd like to do something like:

13 messages 2007/06/10

[#254975] Overloading Array Subtraction operator — Nicko <anko.com@...>

Hi,

15 messages 2007/06/10
[#254978] Re: Overloading Array Subtraction operator — "Erwin Abbott" <erwin.abbott@...> 2007/06/10

The - operator compares objects by their ID, so they aren't removed

[#254986] JRuby 1.0 Released — Thomas Enebo <Thomas.Enebo@...>

The JRuby community is pleased to announce the release of JRuby 1.0!

14 messages 2007/06/10

[#254989] fun with "case" — Robert Klemme <shortcutter@...>

16 messages 2007/06/10

[#255013] Serious danger of being impressed — Mark Carter <me@...>

I'm mostly into Python, and decided to have a go at writing a little

34 messages 2007/06/10
[#255038] Re: Serious danger of being impressed — Chad Perrin <perrin@...> 2007/06/10

On Mon, Jun 11, 2007 at 12:20:12AM +0900, Mark Carter wrote:

[#255096] Re: Serious danger of being impressed — John Joyce <dangerwillrobinsondanger@...> 2007/06/11

[#255103] Re: Serious danger of being impressed — Chad Perrin <perrin@...> 2007/06/11

On Mon, Jun 11, 2007 at 03:42:03PM +0900, John Joyce wrote:

[#255044] Requiring more than one file? — Marc Heiler <shevegen@...>

require does accept ony word, which should be the name that has

13 messages 2007/06/10

[#255142] Custom Mutex methods undefined by fastthread — Alex Young <alex@...>

At the risk of asking an FAQ, I've run into the following problem:

12 messages 2007/06/11

[#255181] a matter of style — Bas van Gils <bas@...>

22 messages 2007/06/11
[#255188] Re: a matter of style — Anthony Martinez <pi@...> 2007/06/11

On Tue, Jun 12, 2007 at 03:10:49AM +0900, Bas van Gils wrote:

[#255299] Re: a matter of style — dblack@... 2007/06/12

Hi --

[#255202] Ruby way to update a file in place — Li Chen <chen_li3@...>

Hi all,

12 messages 2007/06/11

[#255258] how to make a[2][2][3]=4 work? — gz zz <gpygood@126.com>

a=Hash.new{|h,k|

16 messages 2007/06/12

[#255289] Generate a grid of cells, and give characteristics — Joop Van den tillaart <tillaart36@...>

Hi you all I am new to this forum and also quite new to ruby...I have

12 messages 2007/06/12
[#255303] Re: Generate a grid of cells, and give characteristics — "Harry Kakueki" <list.push@...> 2007/06/12

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

[#255306] Re: Generate a grid of cells, and give characteristics — Joop Van den tillaart <tillaart36@...> 2007/06/12

Harry Kakueki wrote:

[#255315] Re: Generate a grid of cells, and give characteristics — "Harry Kakueki" <list.push@...> 2007/06/12

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

[#255373] Quick sed replacemnt — yitzhakbg <yitzhakbg@...>

I need a quicky which I can't do in sed and I did it very clumsily.

14 messages 2007/06/12

[#255651] Changing registry values with Win32::Registry — Collin Miller <collintmiller@...>

I'm trying to change a registry value for an IPTV SDK

12 messages 2007/06/14
[#255699] Re: Changing registry values with Win32::Registry — "Jano Svitok" <jan.svitok@...> 2007/06/15

On 6/14/07, Collin Miller <collintmiller@gmail.com> wrote:> I'm trying to change a registry value for an IPTV SDK>> This code:>> Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\> \").write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)>> Returns this error:>> Win32::Registry::Error: Access is denied.> from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'> from (irb):150> from ⊂:0>> Anybody know how I can ensure access to this key?

[#255664] Reasonable practice? — Trans <transfire@...>

It the following reasonable? How thread safe is it?

14 messages 2007/06/14

[#255672] Re: class destruction (evil genius metaprogramming) — "Rick DeNatale" <rick.denatale@...>

On 6/14/07, Giles Bowkett <gilesb@gmail.com> wrote:

12 messages 2007/06/15

[#255737] Verbal Arithmetic (#128) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

29 messages 2007/06/15

[#255760] Using extend for initialization settings? — Trans <transfire@...>

It's not uncommon to see initialize method take a hash or a setting

16 messages 2007/06/15
[#255784] Re: Using extend for initialization settings? — Robert Klemme <shortcutter@...> 2007/06/15

On 15.06.2007 16:44, Trans wrote:

[#255797] Re: Using extend for initialization settings? — Trans <transfire@...> 2007/06/15

[#255864] Adding new value (in array) to existing key in a hash — Gilbert Lau <gilbertlsk@...>

Hi all,

12 messages 2007/06/16
[#255866] Re: Adding new value (in array) to existing key in a hash — "Harry Kakueki" <list.push@...> 2007/06/16

On 6/16/07, Gilbert Lau <gilbertlsk@gmail.com> wrote:

[#255873] Re: Adding new value (in array) to existing key in a hash — Gilbert Lau <gilbertlsk@...> 2007/06/16

Harry Kakueki wrote:

[#255871] Error in ancestor? — "Robert Dober" <robert.dober@...>

Hi list

39 messages 2007/06/16
[#256036] Re: Error in ancestor? — Sylvain Joyeux <sylvain.joyeux@...> 2007/06/18

I launched a discussion about this on Ruby-core. I think there were no

[#256193] Re: Error in ancestor? — "Robert Dober" <robert.dober@...> 2007/06/19

On 6/18/07, Sylvain Joyeux <sylvain.joyeux@polytechnique.org> wrote:

[#256204] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/19

On 6/19/07, Robert Dober <robert.dober@gmail.com> wrote:

[#256236] Re: Error in ancestor? — dblack@... 2007/06/19

Hi --

[#256486] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/21

On 6/19/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256492] Re: Error in ancestor? — dblack@... 2007/06/21

Hi --

[#256594] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/22

On 6/21/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256595] Re: Error in ancestor? — dblack@... 2007/06/22

Hi --

[#256598] Re: Error in ancestor? — "Gregory Brown" <gregory.t.brown@...> 2007/06/22

On 6/22/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256700] Re: Error in ancestor? — "Rick DeNatale" <rick.denatale@...> 2007/06/23

On 6/22/07, Gregory Brown <gregory.t.brown@gmail.com> wrote:

[#255911] Chris Pine Program Challenges — danielj@...

puts 'Type in as many words as you want'

13 messages 2007/06/16

[#255980] Parsing strings — NB88 <germans88@...>

Quick question, is there a method for deleting substrings from within a

15 messages 2007/06/18

[#256062] Another Easy Beginner Question — danielj <danielj@...>

17 messages 2007/06/18

[#256131] local vars clobbered by un-run code — Trans <transfire@...>

Err...

13 messages 2007/06/19

[#256243] Ruby MVC — poopdeville@...

Hi Everybody,

14 messages 2007/06/20

[#256299] Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...>

Hello everybody,

55 messages 2007/06/20
[#256311] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Trans <transfire@...> 2007/06/20

[#256357] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

>> Hello everybody,

[#256361] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Robert Klemme <shortcutter@...> 2007/06/21

On 21.06.2007 11:06, Alexander Presber wrote:

[#256364] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

Am 21.06.2007 um 11:20 schrieb Robert Klemme:

[#256365] Re: Behaviour of Enumerables reject vs. select mixed into Hash — dblack@... 2007/06/21

Hi --

[#256367] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Robert Dober" <robert.dober@...> 2007/06/21

On 6/21/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256370] Re: Behaviour of Enumerables reject vs. select mixed into Hash — dblack@... 2007/06/21

Hi --

[#256498] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Rick DeNatale" <rick.denatale@...> 2007/06/21

On 6/21/07, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#256369] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

[#256374] Re: Behaviour of Enumerables reject vs. select mixed into Hash — dblack@... 2007/06/21

Hi --

[#256377] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

[#256385] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Robert Dober" <robert.dober@...> 2007/06/21

On 6/21/07, Alexander Presber <aljoscha@weisshuhn.de> wrote:

[#256401] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Trans <transfire@...> 2007/06/21

[#256414] Re: Behaviour of Enumerables reject vs. select mixed into Hash — "Robert Dober" <robert.dober@...> 2007/06/21

On 6/21/07, Trans <transfire@gmail.com> wrote:

[#256423] Re: Behaviour of Enumerables reject vs. select mixed into Hash — Alexander Presber <aljoscha@...> 2007/06/21

>> module Enumerable

[#256310] Do You Understand Regular Expressions? — growlatoe@...

Hi all.

20 messages 2007/06/20
[#256317] Re: Do You Understand Regular Expressions? — "Axel Etzold" <AEtzold@...> 2007/06/20

> irb(main):001:0> "hello".scan(/.*/)

[#256324] Re: Do You Understand Regular Expressions? — Daniel DeLorme <dan-ml@...42.com> 2007/06/20

Axel Etzold wrote:

[#256386] Re: Do You Understand Regular Expressions? — "Stephen Ball" <sdball@...> 2007/06/21

On 6/20/07, Daniel DeLorme <dan-ml@dan42.com> wrote:

[#256426] Ruby extensions question.. — Aaron Smith <beingthexemplary@...>

So I'm getting slightly confused with writing ruby extensions and what

17 messages 2007/06/21
[#256430] Re: Ruby extensions question.. — james.d.masters@... 2007/06/21

On Jun 21, 10:22 am, Aaron Smith <beingthexempl...@gmail.com> wrote:

[#256442] Re: Ruby extensions question.. — Aaron Smith <beingthexemplary@...> 2007/06/21

unknown wrote:

[#256450] Re: Ruby extensions question.. — MenTaLguY <mental@...> 2007/06/21

On Fri, 22 Jun 2007 03:55:11 +0900, Aaron Smith <beingthexemplary@gmail.com> wrote:

[#256469] Re: Ruby extensions question.. — Aaron Smith <beingthexemplary@...> 2007/06/21

MenTaLguY wrote:

[#256473] Re: Ruby extensions question.. — MenTaLguY <mental@...> 2007/06/21

On Fri, 22 Jun 2007 05:28:17 +0900, Aaron Smith <beingthexemplary@gmail.com> wrote:

[#256447] Ruby doesn't know how to multiply — "rjprado@..." <rjprado@...>

Hello,

45 messages 2007/06/21
[#256462] Re: Ruby doesn't know how to multiply — "rjprado@..." <rjprado@...> 2007/06/21

On Jun 21, 3:21 pm, "rjpr...@gmail.com" <rjpr...@gmail.com> wrote:

[#256484] Re: Ruby doesn't know how to multiply — Lloyd Linklater <lloyd@2live4.com> 2007/06/21

> Yes, you are all right. It's a common problem. I have confirmed this

[#256509] Re: Ruby doesn't know how to multiply — Yukihiro Matsumoto <matz@...> 2007/06/22

Hi,

[#256512] Re: Ruby doesn't know how to multiply — "Michael W. Ryder" <_mwryder@...> 2007/06/22

Yukihiro Matsumoto wrote:

[#256514] Re: Ruby doesn't know how to multiply — "Gregory Brown" <gregory.t.brown@...> 2007/06/22

On 6/21/07, Michael W. Ryder <_mwryder@worldnet.att.net> wrote:

[#256517] Re: Ruby doesn't know how to multiply — Rob Biedenharn <Rob@...> 2007/06/22

On Jun 21, 2007, at 8:48 PM, Gregory Brown wrote:

[#256519] Re: Ruby doesn't know how to multiply — "Michael W. Ryder" <_mwryder@...> 2007/06/22

Rob Biedenharn wrote:

[#256556] avoiding nil.methodcalls short and cheap — Thorsten Rossner <rossnet@...>

Hi,

17 messages 2007/06/22

[#256675] Regexp to split name? — Alex MacCaw <maccman@...>

Does anyone have an example of splitting a name into first and last

15 messages 2007/06/23
[#256676] Re: Regexp to split name? — darren kirby <bulliver@...> 2007/06/23

quoth the Alex MacCaw:

[#256713] Named/positional method args — darren kirby <bulliver@...>

I have a method here that takes two arguments. Both are optional, with

19 messages 2007/06/23

[#256748] LSRC Name Picker (#129) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

44 messages 2007/06/24
[#256749] Re: [QUIZ] LSRC Name Picker (#129) — James Edward Gray II <james@...> 2007/06/24

Sorry the quiz was late this week.

[#256811] Helper to create multi-dimensional arrays — Anthony Martinez <pi@...>

I came up with this method really quick to create x*y arrays in Ruby. It

21 messages 2007/06/24
[#256816] Ruby Debugger — Dick Summerfield <ds@...> 2007/06/24

Hello everybody,

[#257017] Probably an FAQ, but... — David Rush <kumoyuki@...>

Hi all,

13 messages 2007/06/26
[#257023] Re: Probably an FAQ, but... — Morton Goldberg <m_goldberg@...> 2007/06/26

On Jun 26, 2007, at 5:00 AM, David Rush wrote:

[#257033] how much to charge for a freelance project in ruby in the states — urielka <uriel.katz@...>

i work in Israel and i wanted to know how much should i charge per

9 messages 2007/06/26

[#257207] ActiveRecord (not necessarily rails) — "shawn bright" <nephish@...>

Hello all,

11 messages 2007/06/27

[#257228] Ajax with Ruby problem — Gale CC <galecho@...>

I'm a newbie to both Ruby and Ajax. I'm trying to use Ruby to handle the

13 messages 2007/06/27

[#257246] Array Problem, sort Array — Cool Wong <coolwong85@...>

[code]

23 messages 2007/06/28
[#257248] Re: Array Problem, sort Array — "list. rb" <list.rb@...> 2007/06/28

["a", "a", "a", "b", "b", "c", "c", "c","d", "d", "e"].uniq.sort

[#257342] Help with regular expression — "toulax@..." <toulax@...>

How can I make a regular expression that will match everything, unless

17 messages 2007/06/28
[#257343] Re: Help with regular expression — Philip Hallstrom <ruby@...> 2007/06/28

> How can I make a regular expression that will match everything, unless

[#257346] Re: Help with regular expression — "toulax@..." <toulax@...> 2007/06/28

On Jun 28, 4:00 pm, Philip Hallstrom <r...@philip.pjkh.com> wrote:

[#257353] Re: Help with regular expression — "Axel Etzold" <AEtzold@...> 2007/06/28

I think what you want is what's called negative lookahead.

[#257383] newby non/programmer trying to understand classes — "weathercoach@..." <weathercoach@...>

Hello.

15 messages 2007/06/28

[#257428] Where to start in parsing? — "Hakusa@..." <Hakusa@...>

I haven't programmed in a while, but I want to get back with doing

10 messages 2007/06/29

[#257454] Feature Request: Special file '-' denoting stdin/stdout — "Ronald Fischer" <ronald.fischer@...>

I would like to propose a feature for Ruby which can be

12 messages 2007/06/29
[#257471] Re: Feature Request: Special file '-' denoting stdin/stdout — Erik Veenstra <erikveen@...> 2007/06/29

It should be mentioned that both File.new and File.open are

[#257746] Re: Feature Request: Special file '-' denoting stdin/stdout — "Ronald Fischer" <ronald.fischer@...> 2007/07/02

[#257573] is it bug? for — Chung Chung <bkeh12@...>

[root@home1 ~]# ruby -v

16 messages 2007/06/30

[#257601] de-camelcase a filename — Aaron Smith <beingthexemplary@...>

how can a take a string file name like MyTestCase.rb and change it to

15 messages 2007/06/30

[#257609] apt-get installs 1.8.5 on ubuntu 7.0.4 — "D. Krmpotic" <david.krmpotic@...>

hi!

11 messages 2007/06/30

Gecode/R - Request for syntax feedback

From: Andreas Launila <ruby-talk@...>
Date: 2007-06-05 19:43:37 UTC
List: ruby-talk #254467
Hello, I'm working on Gecode/R, a Ruby interface to Gecode[0], allowing
constraint programming in Ruby. I'm currently trying to set some
goals/direction for the syntax, and would appreciate feedback from
anyone that has the interest and time. The interface is intended for
people with no previous experience of constraint programming, and should
be fairly easy for an average ruby programmer (i.e. someone familiar
with Ruby) to pick up and use.

I begin with a short introduction and example, I will then highlight
some problems and things to consider. I have formulated some actual
questions in the end of some paragraph, but those are mostly there as
aid for the reader. Feel free to disregard them and comment on any thing
that you think of, any sort of feedback is welcome.


== Introduction and example ==

Using constraint programming basically means that you model the problem
by specifying the constraints that have to hold for something to be a
solution to the problem. The underlying engine then solves the problem
by searching for solutions satisfying all the constraints. Lets take
Ruby Quiz #124 (Magic Squares)[1] as an example. For something to be a
solution to that problem we require that the elements are distinct,
between 1 and n^2, and that the sum of the rows, columns and two main
diagonals are equal. So we model that with some code and then let the
underlying engine do a search.

The following is an example of how solving the problem might look.


# A na阮e model of the magic square problem with square size n.
class MagicSquare < Gecode::Model
  # n is the size of the magic square.
  def initialize(n)
    # This models that all elements are in 1..(n**2) and are all
    # distinct. IntVar.matrix produces an instance of Matrix filled
    # with instances of IntVar.
    squares = IntVar.matrix(n, n, 1..(n**2))
    all_distinct squares

    # The following models the part about various sums being equal. We
    # know the magic sum (row sum) since we know the sum of all
    # elements.
    magic_sum = n*(1 + n**2) / 2
    n.times do |i|
      squares.row(i).to_a.sum == magic_sum
      squares.column(i).to_a.sum == magic_sum
    end
    squares.diagonal(0, 0).sum == magic_sum
    squares.diagonal(0, squares.column_size - 1).sum == magic_sum

    # We need to select a branching strategy, this is used when we can
    # no longer prune impossible values by deduction and have to make a
    # guess.
    branch_on squares, :variable => :min_size, :value => :min
  end
end

# A couple of utility methods for Array and Matrix to make the above a
# bit more readable.
class Array
  # Folds the elements in the array using the + method.
  def sum
    inject{ |sum, element| sum + element }
  end
end
class Matrix
  # Returns an array containing the element found in the diagonal which
  # contains the element in the specified row and column and contains no
  # element with a strictly smaller row-index. nil is returned if such a
  # diagonal does not exist.
  def diagonal(row, column)
    # Out of bounds.
    return nil unless row < row_size and column < column_size
    # Does not exist.
    return nil if row > 0 and column != 0 and column != column_size - 1

    diag_length = [row_size - row, column_size - column].min
    elements = []
    diag_length.times do |offset|
      elements << self[row + offset, column + offset]
    end
    return elements
  end
end

# Print a solution (the first we find). This assumes that the solution
# has some decent default to_s method.
puts MagicSquare.new(9).solution.to_s


With the above syntax each problem is described as a class inheriting
from some common superclass. The actual model is defined in the
constructor. Each model has a number of variables that define the space
that the engine should search through, in our case we have a n*n matrix
with integers which can take values in the range 1..n**2 . Ruby's Array
and Matrix are used as collections (so IntVar.matrix is just a
convenience method for creating an instance of Matrix and filling it
with instances of IntVar). The advantage with that is that we get all
the utility that we're used to, along with Array's special syntax for
construction.


== Issues ==

=== Describing (linear) constraints ===

In the above example we describe our constraints with lines such as
"squares.diagonal(0, 0).sum == magic_sum". In this case we define a
linear equation that has to hold. These are not lines that are evaluated
to true or false, rather they have the side effect of creating a
constraint that has to hold. The instances of IntVar define arithmetic
methods to create a temporary representation which can then be further
added on to by e.g. more use of arithmetic methods. The representations
are kept track of behind the scenes and translated to real constraints
in the end. Lets take an example:

x,y,z = IntVar.array(3, 0..9) # Three variables with domain 0..9.
x + y == z

"x + y" would evaluate to a temporary representation which is stored and
then has "== z" applied to it.

A problem with the above is that people might look at it and
instinctively think that it's something that does not have a side
effect. Therefore prepending some sort of method might convey that
intention better. For instance we could allow people to write the following.

constrain x + y == z

Fitting words other than "constrain" might be "assert", "post" and
"add". One could also go a bit further and make using such a prepended
method compulsory for consistency. I guess the real question is how
disturbing it is for an average Ruby programmer to have arithmetic
methods that have side effects. Do you see it as natural, disturbing or
something in between? Can you think of any way of making the intention
of there being a side effect clearer?

Using arithmetic and comparison methods is of course only one way of
many to describe these (linear) constraints. One drawback with it is
consistency. Since != can't be redefined to be something other than !(x
== y) inequality has to be treated differently. In this case I'm
considering using something similar to "x.not_equal(y)", i.e. just
replace "!=" with "not_equal". There are a lot of constraints, but these
linear constraints are amongst the most common. Can you think of better
ways to represent them?

=== Variable access ===

Something that the above example doesn't really bother with is some way
to allow the variables to be accessed as something other than local
variables. For instance we might want to write a better to_s method
where we need access to the variables in the squares matrix (which hold
that information).

One way that should be familiar is to have the user save squares in an
instance variable (e.g. @squares) that can then be accessed other where.
Other approaches might include trying to save all instance variables
created in the constructor that refer to instances of e.g. IntVar and
then create methods for accessing them. Yet another would be to have the
user explicitly declare variables (possibly on a class level), which
would then be accessible anywhere in the instance. What would you suggest?

=== Describing distinct constraints ===

The "all_distinct squares" line adds a constraint that says that all
variables contained in squares have to be pairwise inequal. Other names
than "all_distinct" could be used, for example "distinct" and
"all_different" (Gecode uses "distinct"). Other ways of specifying the
constraint could also be imagined, such as "squares.all_distinct". The
latter could make things a bit more consistent by allowing a method to
be prepended, such as "constrain squares.all_distinct" (assuming such a
prepended method is used for the linear constraints). What feels more
natural/readable?

=== Overall syntax ===

Every model has at least three parts:
* Declaration of variables (in the example that would be "squares = ...")
* Definition of constraints (all the lines from "all_distinct ..." down
to "squares.diagonal..." in the example).
* Selection of branching strategy (the line starting with "branch_on" in
the example)

Maybe that could be used to produce some other overall syntax? E.g.
something other than throwing it all into a constructor.


== Conclusion ==

Any feedback (pointing out flaws, suggesting modifications, suggesting a
completely different syntax, anything) is appreciated. Questions about
the project, constraint programming, what has to be covered by the
syntax etc are also welcome.

There are more issues that I would like feedback on, but I figured that
it might be best to start with these and then introduce other areas as
the discussion progresses. I'm trying to collect syntax ideas on a
wiki-page[2], that page gives an overview of the majority of the areas
that the syntax will have to cover. It's more of a collection of notes
and thoughts than proposals though, so it might be hard to read but
possibly interesting to someone.


[0] http://www.gecode.org/
[1] http://www.rubyquiz.com/quiz124.html
[2] http://gecoder.lokorin.org/dev/wiki/Syntax_ideas

-- 
Andreas Launila

In This Thread

Prev Next