[#380721] Can you search in REXML by attributes? — "Kyle X." <haebooty@...>
Hello and thank you to all the wonderful and helpful people at this
Thank you Jesus, that is exactly what I was looking for and it works
On Fri, Apr 1, 2011 at 2:53 AM, Kyle X. <haebooty@yahoo.com> wrote:
Robert K. wrote in post #990336:
On Fri, Apr 1, 2011 at 6:27 PM, Kyle X. <haebooty@yahoo.com> wrote:
"Jes=C3=BAs Gabriel y Gal=C3=A1n" <jgabrielygalan@gmail.com> wrote in pos=
Kyle X. wrote in post #992033:
On Mon, Apr 11, 2011 at 1:27 AM, Kyle X. <haebooty@yahoo.com> wrote:
> This works for me:
On Mon, Apr 11, 2011 at 8:57 PM, Kyle X. <haebooty@yahoo.com> wrote:
[#380734] SImple question about file io — Paul Joyce <pjoyce@...>
Hello there
[#380753] AffirmIt! 3.1.4 announced — Eric Galluzzo <egalluzzo@...>
Are you a developer? Testing framework got you down?
On Fri, Apr 1, 2011 at 9:27 AM, Eric Galluzzo <egalluzzo@gmail.com> wrote:
wow... thats a very interesting way to write tests :P *is checking it out
[#380757] computer hacking tips — rakish <rakishkrishna@...>
www.rakishcan.blogspot.com
On Sat, Apr 02, 2011 at 01:45:26AM +0900, rakish wrote:
[#380762] Searching a CSV file - beginner seeking help — Simon Harrison <simon@...>
Hi all. I've written a little script to search a csv file for films. It
[#380782] Reading XML to relational tables — Ted Flethuseo <flethuseo@...>
Hi everyone,
[#380790] Tk and Tile with Tk8.5 — László Földes <foldes.laszlo2@...>
I want to use Ruby 1.9.1 (Ubuntu 10.10) with Tk8.5 Tile, but this samle
L=C3=A1szl=C3=B3 F=C3=B6ldes wrote in post #990509:
Albert Schlef wrote in post #990613:
[#380803] How to make stand a lone Shoes apps (with require 'shoes') — "Superpelican X." <superpelican12@...>
Hello everyone,
hey, i'm pretty sure you just need " require 'shoes' " not shoes3... at
[#380810] Ruby Newbie... — Glenn <hgic@...>
Good Day! I am attempting to install Jobsworth on FreeBSD 8.1-RELEASE
[#380818] Using variables in modules — Stefan Salewski <mail@...>
Can I define a variable in a module, and access and redefine it later?
[#380843] Using grep on subarrays - help! — Simon Harrison <simon@...>
Can anyone help with this? I thought grep would find any element that
On Sun, Apr 3, 2011 at 3:32 PM, Simon Harrison <simon@simonharrison.net> wrote:
[#380849] Splitting each_cons? — Simon Harrison <simon@...>
I'm not sure if each_cons can do what I'm trying to achieve:
[#380883] pipe question — wolf volpi <wolf_volpi@...>
What does the pipe in this example do?
On Sun, Apr 3, 2011 at 9:58 PM, wolf volpi <wolf_volpi@yahoo.com> wrote:
Josh Cheek wrote in post #990762:
[#380902] Move comp.lang.ruby to moderation / message filtering? — Phillip Gawlowski <cmdjackryan@...>
All,
On Mon, Apr 4, 2011 at 12:09 PM, Phillip Gawlowski
On Mon, Apr 4, 2011 at 1:06 PM, Robert Klemme
On 04.04.2011 14:22, Phillip Gawlowski wrote:
[#380909] Query for Ruby and mechanize gem on AIX 5.3 — "Vivek J." <jain.vivek86@...>
Hello
[#380934] Complier Issue in AIX 5.3 — "Vivek J." <jain.vivek86@...>
Hello
[#380949] functional languages -- any recommendations? — 7stud -- <bbxx789_05ss@...>
Haskell, Scala, or Erlang? Which one is the best?
On Tue, 5 Apr 2011 10:17:39 +0900
Johnny M. wrote in post #990966:
[#380963] Autoconvert object from one class1 to other class2 in class1 def — Luk Mus <support@...4u.su>
Is it possible to convert from one Class1 to another Class2 within the
Luk Mus wrote in post #990946:
[#380969] Non-correcting library for parsing/modifying broken HTML/PHP files? — Markus Fischer <markus@...>
Hi,
[#380977] Separate new lines from an output — "Leo M." <leo.mmcm@...>
Hello!
Sorry for being imprecise.
On 5 April 2011 11:38, Leo M. <leo.mmcm@gmail.com> wrote:
On Tue, Apr 5, 2011 at 12:59 PM, Peter Hickman
[#380997] Seeking advice — Alex Rothbard <alex323@...>
Hi. I am writing a library that will have the ability to access a server
[#381015] Match a pattern multiple times, returning matches, captures and offset? — Markus Fischer <markus@...>
Hi,
You can also get the relative offset like this:
7stud -- wrote in post #991338:
Brian Candler wrote in post #991406:
[#381035] capture the output of a grandchild — Chandan Bansal <chandan89@...>
hi
Chandan Bansal wrote in post #991188:
Here's a simple test you can do:
Brian Candler wrote in post #991223:
Chandan Bansal wrote in post #991446:
Brian Candler wrote in post #991449:
Hi,
[#381042] Proc#== behaviour (from Ruby-Core) — Adam Prescott <adam@...>
I did ask this question on Ruby-Core a few days ago, but no-one has replied
In case you didn't know, procs and lambdas in ruby are a mess.
[#381048] String#each_*slice* methods (like Enumerable#each_slice) — "Aaron D. Gifford" <astounding@...>
Hi,
Am 06.04.2011 19:52, schrieb Aaron D. Gifford:
[#381058] Windows 2008 Server: Reading Text File with Ruby. — Angelo NN <storm8000@...>
Hello -
[#381075] Hello — Moises Montenegro <moemonty@...>
Hello,
hello I am trying to get it stated myself, but I am not sure if I am setting Ruby up right.
I am having a hard time to get it up and running. that is Ruby and Ruby on Rails. it seems that no one is willing to help so that we can enjoy this porgram. If their anyway that I can get it downloaded to me, some help to make sure that have the right porgrams.
No one is willing to help? That doesn't sound like the ruby on rails
does the Free Ride program for Ruby the command program that I need to run and write my program?
is there a disk that we can seen off and use. so that we can all the parts of ruby and ruby on rails. I would like this disk.
James Nathan wrote in post #992175:
On 2011-04-11, at 16:50, jake kaiden wrote:
I will just give up on Ruby and Ruby on Rails for now=20
No, I will try another program to learn to write a program. Ruby is just to=
On Tue, Apr 12, 2011 at 3:27 PM, James Nathan <badlands_2004@yahoo.com> wrote:
On Tue, Apr 12, 2011 at 7:59 PM, Phillip Gawlowski
Are you working with Windows?
does ruby need the visual studio 2008 to run?
On 2011-04-12, at 18:27, James Nathan wrote:
Hi all,
FreeRIDE hasn't been worked on in years, and can be considered
[#381087] Hash Surprises with Fixnum, #hash, and #eql? — Clifford Heath <no@...>
Folk,
On Thu, Apr 7, 2011 at 6:05 AM, Clifford Heath <no@spam.please.net> wrote:
On Thu, Apr 7, 2011 at 11:19 AM, Robert Klemme
On Thu, Apr 7, 2011 at 1:20 PM, Phillip Gawlowski
On Thu, Apr 7, 2011 at 1:53 PM, Robert Klemme
On Thu, Apr 7, 2011 at 3:21 PM, Phillip Gawlowski
On Thu, Apr 7, 2011 at 3:43 PM, Robert Klemme
On Thu, Apr 7, 2011 at 4:02 PM, Phillip Gawlowski
On Thu, Apr 7, 2011 at 4:28 PM, Robert Klemme
On 04/07/11 19:19, Robert Klemme wrote:
On Fri, Apr 8, 2011 at 9:30 AM, Clifford Heath <no@spam.please.net> wrote:
On 04/08/11 20:12, Robert Klemme wrote:
Top-replying with a general observation: you can't please everyone all the =
On 04/11/11 10:02, Charles Oliver Nutter wrote:
On Mon, Apr 11, 2011 at 5:20 AM, Clifford Heath <no@spam.please.net> wrote:
On 04/12/11 19:09, Robert Klemme wrote:
On Tue, Apr 12, 2011 at 9:05 PM, Clifford Heath <no@spam.please.net> wrote:
On 04/13/11 15:51, Charles Oliver Nutter wrote:
On Wed, Apr 13, 2011 at 1:35 AM, Clifford Heath <no@spam.please.net> wrote:
On 04/13/11 22:23, Charles Oliver Nutter wrote:
On Wed, Apr 13, 2011 at 4:40 PM, Clifford Heath <no@spam.please.net> wrote:
On 04/14/11 15:36, Charles Oliver Nutter wrote:
On Thu, Apr 14, 2011 at 12:55 AM, Clifford Heath <no@spam.please.net> wrote=
Charles,
On Thu, Apr 21, 2011 at 4:53 AM, Clifford Heath <no@spam.please.net> wrote:
On Thu, Apr 21, 2011 at 6:28 AM, Robert Klemme
On Wed, Apr 20, 2011 at 9:53 PM, Clifford Heath <no@spam.please.net> wrote:
[#381088] Packing and unpacking unsigned integers of arbitrary size as binary strings — "Aaron D. Gifford" <astounding@...>
I see there's a 'w' option to pack for packing arbitrary sized
Aaron D. Gifford wrote in post #991376:
[#381090] can we use direct ruby instaed of javascript ? — Sniper Abandon <sathish.salem.1984@...>
Hi Ninjas,
On Thu, 7 Apr 2011 15:44:50 +0900, Sniper Abandon wrote:
On Thu, Apr 07, 2011 at 09:50:14PM +0900, Peter Zotov wrote:
On Fri, 8 Apr 2011 01:48:58 +0900, Chad Perrin wrote:
On Fri, Apr 08, 2011 at 05:37:49AM +0900, Peter Zotov wrote:
I think it might be actually quite interesting for the original poster =
On Thu, Apr 7, 2011 at 11:46 PM, Julian Leviston <julian@coretech.net.au>wrote:
On 8 April 2011 15:03, Josh Cheek <josh.cheek@gmail.com> wrote:
On 2011-04-11 5:45 AM, Michal Suchanek wrote
[#381103] convert string to datetime — Fan Jin <jeff_yq@...>
Hi folks:
[#381118] Windows directories not recognized by ruby? — "Kalman H." <kalmanh@...>
What's wrong with this code?
[#381125] String.gsub with regex and block — Alexey Petrushin <axyd80@...>
Probably a stupid question, but is there a way to use :gsub replacement
[#381134] newlines in array problem — Cyril Joe <cyril_jose@...>
Is there a way to get rid of newlines in an array?
each() doesn't create a new array. Why not use map()? And you need to
[#381183] How do I trap Ctrl-C so it doesn't reach spawned threads? — Jens Carlberg <jens.carlberg@...>
Hi!
On Fri, Apr 8, 2011 at 2:53 AM, Jens Carlberg
[#381191] How to know whether current Fiber is the root Fiber? — Iñaki Baz Castillo <ibc@...>
Hi, calling Fiber.yield without being in the context of a created
How about catching the exception?
[#381193] Checkinstall fails to create a Ruby 1.9.2 package — "P. A." <shamaoke@...>
Hi.
[#381210] Calling to_enum on a MatchData object — Vahagn Hayrapetyan <vahagnh@...>
Hi, I have the following snippet of code:
Thank you for your explanations, I can see now that :each is an
Here's how you can use an enumerator to create an infinite array, from
7stud -- wrote in post #991942:
[#381227] to_yaml in utf-8 encoding — Alexey Petrushin <axyd80@...>
Hello, can you please help me with this tricky problem:
[#381268] File.open very basic — Brett Kruger <brett.a.kruger@...>
Hello, I'm very new to Ruby, and trying to follow the examples in
[#381281] Copying parameters to singleton class — Lars Olsson <lasso@...>
Hi list!
On Mon, Apr 11, 2011 at 11:20 AM, Lars Olsson <lasso@lassoweb.se> wrote:
[#381282] Beginner's Beginner — william nelson <wanelson23@...>
I am trying to execute the Sudoku Solver listed in the book "The Ruby
By requiring Sudoku, you're loading the contents of the file sudoku.rb which
On Mon, Apr 11, 2011 at 12:20 PM, Gerard Cahill <gerard.cahill@gmail.com> wrote:
[#381306] Creating a full application with Ruby — Fily Salas <fs_tigre@...>
Hi,
Thank you all for your reply.
[#381342] puts box.dup.enlarge(4, 5) -- unexpected result — Stefan Salewski <mail@...>
Hello,
[#381355] Ruby for beginners (was: Re: Hello) — Phillip Gawlowski <cmdjackryan@...>
On Tue, Apr 12, 2011 at 5:08 PM, Vincent Manis <vmanis@telus.net> wrote:
I agree that this is an important need. I suspect Ruby is not as
On Wed, Apr 13, 2011 at 11:14 AM, Jim Maher <jdmaher@jdmaher.com> wrote:
On Tue, Apr 12, 2011 at 10:30 AM, Phillip Gawlowski <
On Tue, Apr 12, 2011 at 7:48 PM, andrew mcelroy <sophrinix@gmail.com> wrote:
OK, so here's another kick at the can.=20
For what it's worth I have been using interactive_editor gem in irb for a
On Tue, Apr 12, 2011 at 8:30 PM, Vincent Manis <vmanis@telus.net> wrote:
On 2011-04-13, at 05:59, Josh Cheek wrote:
On Wed, Apr 13, 2011 at 4:48 PM, Vincent Manis <vmanis@telus.net> wrote:
On 2011-04-13, at 08:03, Phillip Gawlowski wrote:
On Thu, Apr 14, 2011 at 10:35:42AM +0900, Vincent Manis wrote:
On Thu, Apr 14, 2011 at 5:03 AM, Chad Perrin <code@apotheon.net> wrote:
I've deleted any context to which I didn't feel a need to respond; it
On Thu, Apr 14, 2011 at 6:21 PM, Chad Perrin <code@apotheon.net> wrote:
On Fri, Apr 15, 2011 at 01:45:01AM +0900, Phillip Gawlowski wrote:
On Thu, Apr 14, 2011 at 9:16 PM, Chad Perrin <code@apotheon.net> wrote:
I've been out of the loop for the last day or so, so I've bundled up my =
[#381377] Building extensions into static libraries — Alex Young <alex@...>
I am delving into the wonder that is mkmf.rb. I'm trying to tell
[#381384] hash of arrays — David Sprague <david.sprague@...>
I'm wrote this code to bin a list of words by word-length:
[#381397] Ruby Cross Reference — Peter Zotov <whitequark@...>
I'm pleased to announce that Ruby Cross Reference has just been rolled
[#381398] problem with swig & ruby — serialhex <serialhex@...>
ok, so i'm working on a project that requires me to use swig to write some
[#381423] so, who's writing a dedicated ruby ide? — Martin DeMello <martindemello@...>
The recent thread on newbie-friendliness and a "ruby in a box" IDE
RubyMine from JetBrains
On Wed, Apr 13, 2011 at 8:32 AM, Sebastian Bachmann <
On 2011-04-13, at 08:29, andrew mcelroy wrote:
On Thu, Apr 14, 2011 at 10:46:02AM +0900, Vincent Manis wrote:
[#381444] Tk : non blocking Tk.mainloop — Juju SL <jujusl@...>
Hi all,
So, I patched manually the tk.rb file :
Thank you for your reply.
Good morning,
[#381454] HTTP request, with headers, post data and SSL :( — "Stuffe L." <stuffe.dk@...>
Hello everyone
[#381474] Help on hashing multiple keys and values — Adam Adam <adam_sateriale@...>
I'm trying to create a hash with multiple values per key from a tab
[#381480] removing nodes from Nokogiri::XML::NodeSet — Ted Flethuseo <flethuseo@...>
Hi everyone,
[#381499] Noob question re:returning nil — Nathan McDorman <nmcdorman@...>
Hello all, I am a beginner programmer and a beginner to Ruby. I was just
[#381511] problems using ruby-ldap to connect with windows AD — kang cao <cooker_bj@...>
hi:
I have figured out the problem. MY windows AD is listening on 389, not
[#381525] Exclusive float range, Range#step result in counterintuitive result — Joey Zhou <yimutang@...>
Hi everybody,
[#381547] Running Ruby script in emacs — duke <sidney.reilley.ii@...>
Hey ...
[#381548] To Yield or Not to Yield: An Inferable Question — Michael Edgar <adgar@...>
Hi Rubyists,
Points I'd raise:
Hi Brian =96 Thanks for sharing your thoughts! Since much of what you =
Michael Edgar wrote in post #993395:
On Apr 20, 2011, at 4:59 AM, Brian Candler wrote:
You are of course right in your analysis.
On Thu, Apr 14, 2011 at 7:47 PM, Michael Edgar <adgar@carboni.ca> wrote:
It is the correct link, we had some unscheduled downtime. My apologies. =
[#381549] Take a look it this online interpreter — Fily Salas <fs_tigre@...>
Hi,
I didn't know something like this existed. Thats awesome because I can
On 2011-04-14, at 17:40, Fily Salas wrote:
[#381562] What do you do when you need to attach data to an object instance? — "Aaron D. Gifford" <astounding@...>
What do you do when you see a need to be able to attach some data to
Aaron D. Gifford wrote in post #992841:
On Thu, Apr 14, 2011 at 3:11 PM, Kevin Mahler <kevin.mahler@yahoo.com> wrot=
> On Thu, Apr 14, 2011 at 3:11 PM, Kevin Mahler <kevin.mahler@yahoo.com> wrote:
Aaron D. Gifford wrote in post #992887:
Thanks 7stud for the food for thought. And thanks again, Kevin, for
On Fri, Apr 15, 2011 at 8:35 AM, Aaron D. Gifford <astounding@gmail.com> wr=
Kevin Mahler wrote in post #992907:
7stud -- wrote in post #993115:
[#381567] Re: Chad Perrin — Everett L Williams II <rett@...>
*Hasn't anybody in the management of this forum the guts to either quiet
Obvious troll.
[#381591] Understanding global variables. — Fily Salas <fs_tigre@...>
Hi,
[#381602] Feature matrix of Ruby HTTP clients — Hiroshi Nakamura <nahi@...>
Hi,
[#381605] looking for an "inversion" pattern — Fearless Fool <r@...>
I'm sure there's a clean way to do this in Ruby, but I haven't figured
Fearless Fool wrote in post #992929:
[#381615] How to make exe of ruby program on windows? — shilvi parikh <shilvi.parikh@...>
I tried using Rubyscript2exe.rb
[#381622] Get the real object in a Hash key — Iñaki Baz Castillo <ibc@...>
Hi, let's suppose this simple code in which I add internal attributes
On Fri, Apr 15, 2011 at 2:50 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
2011/4/15 Robert Klemme <shortcutter@googlemail.com>:
On Fri, Apr 15, 2011 at 3:14 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
Robert K. wrote in post #993000:
On Fri, Apr 15, 2011 at 4:47 PM, Kevin Mahler <kevin.mahler@yahoo.com> wrot=
[#381644] Extract a range i.e. svr[100..130] ? — Richard Sandoval <skolopen@...>
What best method could extract the range of a given list of servers?
[#381694] Let Ruby read the serial port — "Superpelican X." <superpelican12@...>
Hello everyone,
[#381710] For loops trouble — Daniel Johnson <zaldivar1841@...>
I am trying to translate a program I have in Java into ruby and having
[#381716] Making a simple parser — Felipe Balbi <balbif@...>
Hi all,
[#381724] Released Win32::Screenshot 1.0.3 — Jarmo Pertman <jarmo.p@...>
Hello!
[#381727] Understanding the return method — Fily Salas <fs_tigre@...>
Hi,
[#381742] Telnet "More?" — "Eric T." <erictetz@...>
I'm trying to use the telnet library. I don't know Ruby AT ALL
Eric T. wrote in post #993311:
[#381768] Tail Call Optimization (Tail Recursion) — Terry Michaels <cmhoward@...>
I did some googling to find out if Ruby supports tail call optimization,
7stud -- wrote:
it seems like fib(50000) is not only too big for MRI ruby, but also Python
On 2011-04-18, at 13:40, Louis-Philippe wrote:
Guido has said that any interpreter that implements TCO is not Python.
On 2011-04-18, at 18:42, Steve Klabnik wrote:
[#381775] Using the win32api — antoine crouzi <bourinax@...>
Hi all,
[#381781] Need for speed -> a C extension? — Martin Hansen <mail@...>
Hello all,
Martin Hansen wrote:
WJ wrote in post #993576:
>> def match?(char1, char2)
On Tue, Apr 19, 2011 at 12:30 PM, Martin Hansen <mail@maasha.dk> wrote:
On Tue, Apr 19, 2011 at 6:30 AM, Martin Hansen <mail@maasha.dk> wrote:
unknown wrote in post #993757:
On Tue, Apr 19, 2011 at 10:12 AM, Martin Hansen <mail@maasha.dk> wrote:
> Your Ruby was compiled under 10.7 or 10.6?
Martin Hansen <mail@maasha.dk> wrote:
> Martin Hansen <mail@maasha.dk> wrote:
unknown wrote in post #994006:
On Wed, Apr 20, 2011 at 8:55 AM, Martin Hansen <mail@maasha.dk> wrote:
> Okay, so the issue is in your ruby not RubyInline.
[#381802] Hook into rake for reporting results — milki <milki@...>
Hi,
[#381810] 4 RoR Developers Needed + FREE Bacon! — Larry <lwarrenii@...>
I=92ll be brief! I have 4 open RoR Developer positions working out of
Not really interested in the positions, but how do we get the bacon?
[#381820] help me on this ruby programm — srikanth madakam <sree253@...>
Hi,
[#381822] anonymous closures with Proc,new, lambda and -> — Stu <stu@...>
I am new to the study of functional paradigm. If this question is academic
Stu wrote in post #993687:
Brian Candler wrote in post #993704:
On Tue, Apr 19, 2011 at 3:15 AM, Brian Candler <b.candler@pobox.com> wrote:
how would i break it down to two functions?
Stu wrote in post #993854:
Lots of helpful information in this thread. Thank you all for helping me.
Stu wrote in post #993922:
Naw, monads are actually really, really easy. They're just poorly
Steve Klabnik wrote in post #994098:
Brian Candler wrote in post #994123:
My interest in learning functional programming( or at least the
Stu wrote in post #994213:
+1 for learn you a haskell.
Where does this syntax come from?
7stud -- wrote in post #993798:
Doesn't look like it's really used for anything:
[#381824] How to use Enumerator::Generator in Ruby 1.9.2 — Joey Zhou <yimutang@...>
Hi everybody,
On Tue, Apr 19, 2011 at 8:43 AM, Joey Zhou <yimutang@gmail.com> wrote:
[#381880] assert_name doesn't exist as a function? — Mike RegistrationErr <xandrani@...>
The script (test.rb):
[#381886] Can I check contain value in hash? — Siratinee Sukachai <ploy.sukachai@...>
I have hash which is contain list of string value.
On Wed, Apr 20, 2011 at 6:02 AM, Siratinee Sukachai
[#381891] using hash keys as object name — neubyr <neubyr@...>
How do I assign hash's key as an object name? For example I have a hash as:
On Wed, Apr 20, 2011 at 8:07 AM, neubyr <neubyr@gmail.com> wrote:
Thanks for the help Robert. Following is a scenario I am trying to implemen=
[#381897] Nokogiri parsing question — "Kyle X." <haebooty@...>
Hello, I have beenhaving trouble trying to transform some REXML to
[#381901] Preparing the basic GUI — Rubist Rohit <passionate_programmer@...>
I want to write a small text-editor in Ruby for learning the basics. I
[#381902] splitting binary data — hroyd hroyd <hroyd@...>
Hello
hroyd hroyd wrote in post #993957:
2011/4/20 7stud -- <bbxx789_05ss@yahoo.com>:
[#381915] Control characters in ruby — Arun Kumar <arun.einstein@...>
Hello all,
[#381934] String problem — Cyril Jose <cyril_jose@...>
Hello all,
[#381955] Binary file: SAT — Alessandro Barracco <bomastudio@...>
Hi all. I never work before with binary file, and I'm a bit
Alessandro Barracco wrote in post #994136:
7stud -- wrote in post #994163:
Hi,
Thanx you all. I'm beginning to understand a bit....
[#381958] On the Capitalization of Project Files — Intransition <transfire@...>
I have noticed a trend with regards to the case of project files. In
COPYING is used for GNU things, though I don't know why.
On Thu, Apr 21, 2011 at 08:50:52AM +0900, Johnny Morrice wrote:
[#381973] Using the spaceship operator — RichardOnRails <RichardDummyMailbox58407@...>
Hi,
[#382019] class_eval doesn't find const_missing — Andrew Berkeley <andrew.berkeley.is@...>
I am trying to write a DSL which uses method_missing and const_missing
[#382043] Reversing a string without using array, classes and reverse function — Rubist Rohit <passionate_programmer@...>
I am trying this:
On Fri, 22 Apr 2011 12:54:16 +0900
I attempted below given code, but it is neither displaying result nor
#!/usr/bin/env ruby
On Fri, Apr 22, 2011 at 2:45 AM, Jose Calderon-Celis
What about
@Robert: Thanks, Cheers
[#382049] Can I append hash to hashes? — Siratinee Sukachai <ploy.sukachai@...>
I need to do a hash some kind like this:
[#382065] Split dot and equa sign by recursive — Siratinee Sukachai <ploy.sukachai@...>
I need to do a function which can split dot and equa by recursive.
[#382073] Is it usual/valid to extend custom classes under Errno module? — Iñaki Baz Castillo <ibc@...>
Hi, I've coded a DNS library. When a DNS query fails my library
On Fri, Apr 22, 2011 at 11:15 AM, I=C3=B1aki Baz Castillo <ibc@aliax.net> w=
2011/5/1 Christopher Dicely <cmdicely@gmail.com>:
[#382092] How to split dot “.” only before equal “=” — Sira PS <ploy.sukachai@...>
I need to split dot only before equal to assign to hash
7stud,
[#382107] who can eplain deeply the ruby's methods? — savin max <mafei.198@...>
I wants to know the ruby's methods' describe,the relationship between
[#382108] Are there other Ruby folks using "distributable dynamic agents" for project work? — SwarmShepherd <gmkoller@...>
[#382111] Can I split the array from text? — Sira PS <ploy.sukachai@...>
If I have an array like this
[#382115] Does String#encode in Ruby 1.9.2 have option :fallback? — Joey Zhou <yimutang@...>
My Ruby version is: ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
Hi,
Y. NOBUOKA wrote in post #994724:
[#382123] Set attribute of superclass dinamically — "Jeroen v." <jeroeningen@...>
I have the following code
[#382139] How to run ./script/generate rx_config ? — Sira PS <ploy.sukachai@...>
I'm a newbie and i'm working follow this link
[#382140] problem with ruby19's Hash behavior — Aaron <aaron2ti@...>
see the following codes pls, I wonder if this's a intent or a bug. For me the first line sounds better having same result with the later line
[#382156] Replace any multiple whitespaces with single white space — Michelle Pace <michelle@...>
Hello, I need to make the first string below into the second string.
On 04/25/2011 11:44 AM, Michelle Pace wrote:
On Mon, Apr 25, 2011 at 1:51 PM, Joel VanderWerf
[#382167] ruby-prof 0.10.5 — Roger Pack <rogerpack2005@...>
Pleased to announce ruby-prof gem's 0.10.5
[#382176] Can I Add quotes to values in a array? or include quotes.. — Richard Sandoval <skolopen@...>
Please advise on my situation.
[#382178] no such file to load -- sqlite3 (LoadError) — "Jim S." <jimsyyap@...>
I am learning how to use ruby from the book, 'beginning ruby, novice to
[#382202] Setting a 'reference' inside the method body — Peter Szinek <peter.szinek@...>
Hey guys,
On Tue, Apr 26, 2011 at 4:55 PM, Peter Szinek <peter.szinek@gmail.com> wrot=
[#382215] "cheat" gem — Duke Normandin <dukeofperl@...1.net>
dnormandin@select-man:~$
[#382226] including Enumerable in PStore — Reginald Tan <redge.tan@...>
Hi guys. I want my PStore to act more like a Hash. Basically I want to
[#382228] pattern matching and array methods — Mfer Dez <emphxl@...>
I have a text file that is structured like so:
Something like this should do it :
Dhruva Sagar wrote in post #995263:
[#382236] File.open of HTML file removes code — Scott Elwood <elwood32@...>
Hey there,
[#382246] Fast way to move C array to ruby (rb_ary_new4)? — Ville Sipola <ville_sipola@...>
Good day
On Wed, Apr 27, 2011 at 12:46 PM, Ville Sipola <ville_sipola@hotmail.com> w=
On Wed, Apr 27, 2011 at 2:08 PM, Robert Klemme
[#382250] LoadError in gem — Zhi-Qiang Lei <zhiqiang.lei@...>
Hi,
[#382264] File position and buffers — Cee Joe <cyril_jose@...>
Hi all,
On Wed, Apr 27, 2011 at 10:02 PM, Cee Joe <cyril_jose@ymail.com> wrote:
You still have not told us what you are supposed to do with the stuff =
[#382265] Bounty Request: small sample autoconf-like app/lib — Luis Lavena <luislavena@...>
Hello,
On Wed, Apr 27, 2011 at 22:07, Luis Lavena <luislavena@gmail.com> wrote:
[#382292] Is everything object ? — "amir e." <aef1370@...>
Hi
On Thu, Apr 28, 2011 at 4:48 AM, amir e. <aef1370@gmail.com> wrote:
On Thu, Apr 28, 2011 at 08:52:35PM +0900, Josh Cheek wrote:
On Thu, Apr 28, 2011 at 10:12 AM, Chad Perrin <code@apotheon.net> wrote:
On Fri, Apr 29, 2011 at 02:23:32AM +0900, Josh Cheek wrote:
On Thu, Apr 28, 2011 at 3:22 PM, Chad Perrin <code@apotheon.net> wrote:
On Fri, Apr 29, 2011 at 08:39:14AM +0900, Josh Cheek wrote:
On Thu, Apr 28, 2011 at 10:40 PM, Chad Perrin <code@apotheon.net> wrote:
On Fri, Apr 29, 2011 at 01:09:25PM +0900, Josh Cheek wrote:
On Fri, Apr 29, 2011 at 2:37 PM, Chad Perrin <code@apotheon.net> wrote:
On Sat, Apr 30, 2011 at 08:01:48AM +0900, Josh Cheek wrote:
On Sat, Apr 30, 2011 at 02:15:15PM +0900, Chad Perrin wrote:
On Sat, Apr 30, 2011 at 12:55 AM, Chad Perrin <code@apotheon.net> wrote:
On Sat, Apr 30, 2011 at 04:35:15PM +0900, Josh Cheek wrote:
I like Chad's explanation.
[#382297] Best gem for an existing mysql database — Iain Barnett <iainspeed@...>
Hi,
[#382300] where's the best place to dynamically add singleton method? — Iain Barnett <iainspeed@...>
Hi,
[#382310] Initialize Struct from Hash — Brian Candler <b.candler@...>
I just want to check I've not missed something here. Is there a built-in
On Thu, Apr 28, 2011 at 7:00 PM, Brian Candler <b.candler@pobox.com> wrote:
Thanks for all the feedback, at least I know I hadn't missed something
[#382312] calling methods, beginner help — Ronnie Aa <liquid98@...>
Hello Guys,
Hi Brain,
[#382350] Ruby Beginner Need Help.. — Didin Ibnu Sarnan <didinna@...>
Hi,
Didin Ibnu Sarnan wrote in post #995669:
Hi,
On Fri, Apr 29, 2011 at 12:17:04PM +0900, Didin Ibnu Sarnan wrote:
To install rails you will need sqlite3 installed( though you can use
[#382367] rubygems down ? — Michel Demazure <michel@...>
Is it a rubygems problem or an error of mine ? For two days now :
[#382374] Need for speed - array operations — Chris Lervag <chris.lervag@...>
Hi,
Robert,
[#382393] real life audio data transmit & recive — Md Mosfiqur Rahman <adn_ami@...>
hi
[#382394] must "explanation" {.test.} style not working in my unit tests — Vahagn Hayrapetyan <vahagnh@...>
Hi, I'm trying to use this extension:
[#382401] How do I read HTTP POST XML sent to CGI? — Ting Chang <aumart@...>
Hello Ruby Masters,
[#382426] A Code Point's Tale: There and Back Again — Terry Michaels <cmhoward@...>
This is probably obvious in the docs and I'm just missing it, but here
[#382427] Must be my bug, but it looks like Ruby's ... could it be? — RichardOnRails <RichardDummyMailbox58407@...>
I know my Subject line looks like heresy in this newsgroup, but I
[#382439] question about working with dates — eggman2001 <sodani@...>
I have a list (in database) of weekday non-holiday dates that goes
[#382452] Why defining a constant in a method is not allowed but using self.class.const_set is allowed? — Iñaki Baz Castillo <ibc@...>
Hi, assinging a value to a constant within a method is not allowed
On 30.04.2011 21:25, I=F1aki Baz Castillo wrote:
2011/4/30 Robert Klemme <shortcutter@googlemail.com>:
On Sat, Apr 30, 2011 at 12:58 PM, I=C3=B1aki Baz Castillo <ibc@aliax.net> w=
2011/5/1 Christopher Dicely <cmdicely@gmail.com>:
On Sun, May 1, 2011 at 1:48 AM, I=F1aki Baz Castillo <ibc@aliax.net> wrote:
2011/5/1 Phillip Gawlowski <cmdjackryan@googlemail.com>:
On 01.05.2011 02:24, I=F1aki Baz Castillo wrote:
2011/5/1 Robert Klemme <shortcutter@googlemail.com>:
[ANN] ambit-0.9.1 released
=3D ambit
https://github.com/jimwise/ruby/tree/master/ambit
Author:: Jim Wise (mailto:jwise@draga.com)
Copyright:: Copyright (c) 2011 Jim Wise
License:: 2-clause BSD-Style (see LICENSE.txt)
=3D=3D DESCRIPTION:
This is an all-ruby implementation of choose/fail nondeterministic
programming with branch cut, as described in Chapter 22 of Paul Graham's
<em>On Lisp</em>[1], or Section 4.3 of <em>SICP</em>[2].
=3D=3D HISTORY:
=3D=3D=3D 0.9.1 / 2011-04-26
* Minor documentation improvements
=3D=3D=3D 0.9 / 2011-04-26
* First public release of ambit
=3D=3D REQUIREMENTS:
<b>This code will not work in JRuby or MacRuby (no callcc). It should work
in Ruby 1.9 with minor changes (callcc has moved to the 'continuation'
stdlib).</b>
=3D=3D INSTALL:
To install:=20
$ gem install ambit
=3D=3D DEVELOPERS:
After checking out the source, run:
$ rake newb
This task will install any missing dependencies, run the tests/specs,
and generate the RDoc.
=3D=3D SYNOPSIS:
=3D=3D=3D What is Nondeterministic Programming?
Nondeterministic programming is a novel approach to problems where a program
must find a working solution out of many possible choices. It greatly
simplifies problems such as graph searching, or testing combinations of
values, where there are many possible values to consider, often in some sort
of hierarchical order, but the right combination is not known in advance.
In such a situation, it can be useful to develop a program by pretending
our programming language includes knowledge of the future -- and is thus
able to _choose_ the right answer off the bat, and simply programming as
if this were the case.
A language with support for nondeterministic programming (such as Ruby
with this gem) helps us keep up this pretense by saving the state of
computation (with some limits) whenever we make an important choice. If
we later determine that we did _not_, in fact, make the correct choice
(lacking true language support for knowing the future), we can _fail_ the
current computation, which <em>causes computation to rewind to the last
choice made, and continue as if a different choice had been made</em>.
When all possible choices have been tried, the next time computation
_fails_, computation will be rewound to the previous choice point, and
will continue with the next possible choice from there.
Imagine, for instance, that we wish to test a combination lock with a
three-number combination, with each number between 1 and 10, inclusive.
Instead of writing code ourself to try every possible combination, we
simply proceed as if each choice was the correct one, failing if the lock
fails to open. In short:
first =3D Ambit.choose(1..10)
second =3D Ambit.choose(1..10)
third =3D Ambit.choose(1..10)
Ambit.fail! unless open_lock(first, second, third)
# when we get here, lock is open!
As our language does not actually implement knowledge of the future, this
will still try as many combinations as are needed to find the right one --
but we can program as if it has chosen the right one on the first try!
=3D=3D=3D How to Use This Gem
To get started, include this gem using
require 'rubygems'
require 'ambit'
This gem provides the Ambit module. This module provides several methods
which implement nondeterministic programming.
=3D=3D=3D=3D Choosing and Failing
The central method of Ambit is Ambit::choose.
Ambit::choose takes any enumerable (actually, any object which responds to
#each) as an argument, and begins a nondeterministic generate-and-test
process with the members of this object.
Ambit::choose immediately returns the first member of the enumerable, or
calls Ambit::fail! if the enumerable is empty:
a =3D Ambit::choose([1, 2, 3])
puts a
prints
1
If, later, Ambit::fail! is called, <em>computation is rewound until the
point when Ambit::choose was last called</em>, and the next member of the
enumerable is returned <em>from the same call to Ambit::choose</em>:
a =3D Ambit::choose([1, 2, 3])
Ambit::fail! unless a.even?
puts a
prints
2
(and only "2")
<em>This means that computation now proceeds as if that had been the value
returned by Ambit::choose all along.</em>
As an alternative, Ambit::assert can be used to fail unless a condition
holds. Ambit::assert will rewind to the previous invocation of
Ambit::choose if and only if it's (single) argument is false:
a =3D Ambit::choose([1, 2, 3])
Ambit::assert a.even?
puts a
prints
2
(and only "2")
Note that this call to Ambit::fail! (or Ambit::assert) can occur any amount
of time later, and works <em>even if the function which called choose has
since exited</em>. Execution is still rewound as needed to allow the next
value to be returned from the same call to Ambit::choose.
Calls to Ambit::choose can be nested to arbitrary depth -- each call to
Ambit::fail! will rewind to the <em>most recent</em> call to Ambit::choose.
If that set of choices has already returned every member of its enumerable,
execution is instead rewound to the previous invocation of Ambit::choose,
and execution continues with the next choice from that invocation's
enumerable:
a =3D Ambit::choose([1, 3, 5, 7, 9, 11, 13, 15])
b =3D Ambit::choose([0, 5, 10, 15])
Ambit::assert a =3D=3D b
puts a
prints
5
(and only "5")
If all choices from all past calls to Ambit::choose have been exhausted (or
if Ambit::fail! is called before any call to Ambit::choose), an exception of
type Ambit::ChoicesExhausted is raised instead.
=3D=3D=3D=3D Side Effects
We've talked a lot above about "rewinding" computation to a previous choice
point. Not all computations can be rewound, however -- if the computation
we have performed since the choice point we are rewinding to has had side
effects (other than the choices made), those side effects will not
themselves be rewound. While some side effects (setting of variables) could
theoretically be tracked and undone, this would require very careful
semantics -- nd other side effects could not be undone by any level of
complexity added to our language. If we have printed output to the user,
for instance, no amount of rewinding will make the user forget what he has
seen; while we simulate the ability to see the future and to change the
past, we can, in fact, do neither.
This can sometimes cause confusion. This code, for instance:
a =3D Ambit::choose([1, 2, 3])
puts a
Ambit::fail! unless a.even?
prints
1
2
instead of only "2" -- the printing has already been done by the time we
call Ambit::fail!.
Such side effects can also be useful, however. This code:
i =3D 0
first =3D Ambit.choose(1..10)
second =3D Ambit.choose(1..10)
third =3D Ambit.choose(1..10)
i +=3D 1
Ambit.fail! unless open_lock(first, second, third)
puts i
prints out the number of combinations which were tried in total (since +i+
remains incremented even when we rewind computation).
=3D=3D=3D=3D More Than One Answer
Often, more than one combination of choices is interesting to consider -- it
may be useful, for instance, to see _all_ combinations which do not fail,
instead of only the first.
Since Ambit::fail! will always rewind to the previous choice point, getting
more possible combinations is as easy as calling Ambit::fail! in order to
try the next combination -- even though we have not, strictly, failed. When
no more successful combinations are available, this call to Ambit::fail!
will instead raise an exception of type Ambit::ChoicesExhausted.
begin
a =3D Ambit::choose([1, 3, 5, 7, 9, 11, 13, 15])
b =3D Ambit::choose([0, 5, 10, 15])
Ambit::assert a =3D=3D b
puts a
Ambit::fail!
rescue Ambit::ChoicesExhausted
puts "Done."
end
prints
5
15
Done.
Note that this code, too depends on a side effect -- +a+ is output each time
we get a match, even though we then call Ambit::fail! to rewind computation
and try the next combination.
=3D=3D=3D=3D Cleaning up
Ambit::clear! can be called at any time to eliminate all outstanding choices
on the default Generator, ending nondeterminism (and allowing any
outstanding alternate paths of execution to be garbage collected). This is
most useful when a given computation is finished, so that future invocations
of Ambit::fail! will not restart the now-finished computation with another
choice.
=3D=3D=3D=3D Marking and Cutting
While Ambit::clear! can be used to abandon an entire set of nondeterministic
computations, sometimes it is useful to abandon only one branch of a
computation, while still keeping the ability to rewind to the choice which
first took us down that branch.
Suppose, for instance, that we are trying to guess a word with four letters:
a =3D Ambit::choose('a'..'z')
b =3D Ambit::choose('a'..'z')
c =3D Ambit::choose('a'..'z')
d =3D Ambit::choose('a'..'z')
Ambit::assert good_word(a, b, c, d)
print a, b, c, d
This works. But what if we were able to determine, once all four letters
were chosen, whether the first letter was correct? How would we proceed?
If we failed because the first letter was incorrect, we would continue tryi=
ng
every possible value for the second, third and fourth letters -- even thoug=
h none of
them could be correct. We need a way to rewind to an earlier choice point.
To work around this, Ambit provides a method, Ambit::cut! which "locks in" a
set of past choices, preventing them from being revisited later:
a =3D Ambit::choose('a'..'z')
Ambit::mark
b =3D Ambit::choose('a'..'z')
c =3D Ambit::choose('a'..'z')
d =3D Ambit::choose('a'..'z')
if !good_first_letter(a, b, c, d)
Ambit::cut!=20
Ambit::fail!
end=20=20=20
Ambit::assert good_word(a, b, c, d)
print a, b, c, d
When Ambit::cut! is called in the code above, all choices back to the
<em>most recent</em> call of Ambit::mark are wiped out -- the next call to
Ambit::fail! will rewind to the most recent Ambit::choose invocation
<em>before</em> the most recent call to Ambit::mark.
Ambit::cut! can also be used without Ambit::fail! to "commit" to all choices
since the last call to Ambit::mark -- in this case, we are saying that we
know these choices are good, so if we (later) fail, we want to rewind out of
the whole current branch of computation.
=3D=3D=3D=3D Private Generators
In addition to using methods of the Ambit module directly, another option is
to allocate an Ambit::Generator object explicitly. All methods of the Ambit
module are also available as methods of Ambit::Generator (and in fact, the
module allocates a default Generator object to handle all calls made at the
module level).
Ambit::Generator::new can be used to allocate a new Generator:
nd =3D Ambit::Generator::new
nd.choose('a' .. 'e')
each object allocated in this fashion has its own set of choices, and
failing one will not directly affect others. Nesting choices from different
Generators is a good way to make code confusing, however, and should be
avoided -- this capability is mainly provided to allow multi-threaded
programs to safely use Ambit from more than one thread (see below).
Ambit::Generator#clear! is provided for the same reason as Ambit::clear!,
but it is often clearer to use a new Ambit::Generator object for each
unrelated set of nondeterministic computations.
=3D=3D=3D=3D Compatibility
For historical reasons, Ambit::amb and Ambit::Generator#amb are provided as
aliases for Ambit::choose and Ambit::Generator#choose. Likewise, for
historical reasons, calling Ambit::choose (and Ambit::Generator#choose) with
no arguments is equivalent to calling Ambit::fail! (or
Ambit::Generator#fail!).
For the same reason, Ambit::require and Ambit::Generator#require are
provided as aliases for Ambit::assert and Ambit::Generator#assert.
These aliases allow for a more direct translation of programs written with
the _amb_ operator discussed in _SICP_ and elsewhere.
=3D=3D=3D=3D Interaction with Threading
Given the strong modifications to flow of control which occur when a path of
computation is _failed_, care must be taken when using nondeterministic
programming in a multi-threaded program. The two main ways to do this are:
* perform all nondeterministic programming from a single thread of execution
* give each thread which will be using nondeterministic programming its own=
Ambit::Generator object. This can be done easily using thread local varia=
bles:
def nd_begin
Thread.current[:AMB] =3D Ambit::Generator.new
end
def nd_choose choices
Thread.current[:AMB].choose choices
end
def nd_fail!=20
Thread.current[:AMB].fail!
end
def nd_clear!=20
Thread.current[:AMB].clear!
end
=3D=3D=3D Longer example
This solution to the N queens problem is inspired by the prolog version in
<em>The Art of Prolog</em> by Leon Sterling and Ehud Shapiro[3], but is less
elegant, as this is not prolog (and I am not Sterling or Shapiro).
# we want to place N queens on an NxN chess board. Since we know no tw=
o queens
# can be in the same row, an array of N integers between 0 and N-1 will=
do to
# represent the placement. Since we know no two queens can be in the s=
ame column,
# each number from 1 .. N will appear once in this array; this means t=
he solution
# is a permutation of 1 .. N
# Here is the complete board generator. Next is the test if a position=
is safe.
def queens n, board =3D []
if board.size =3D=3D n
board
else
c =3D Ambit.choose(1..n)
Ambit.fail! unless safe board, c
queens n, board + [c]
end
end
# board is the first M columns of an NxN board, and is valid so far.
# piece is a proposed piece for the M+1th row of the board.
# returns true if piece is a valid placement, false otherwise
def safe board, piece
board.each_with_index do |c, r|
return false if c =3D=3D piece # same column
# they're on the same diagonal if the distance in columns =3D=3D th=
e distance in rows
rdist =3D board.size - r
cdist =3D (piece - c).abs
return false if rdist =3D=3D cdist
end
true
end
The file examples/queens.rb, installed with this gem, contains a version of
this with display code, and a command-line driver to print all solutions for
a given N.
=3D=3D=3D References
[1] Graham, Paul, <em>On Lisp</em>, Prentice Hall, 1993. Available online a=
t http://www.paulgraham.com/onlisp.html
[2] Abelson, Harold and Gerald Jay Sussman, <em>Structure and Interpretatio=
n of Computer Programs, 2nd Edition</em>, MIT Press, 1996. Available onlin=
e at http://mitpress.mit.edu/sicp/
[3] Sterling, Leon and Ehud Shapiro, <em>The Art of Prolog</em>, MIT Press,=
1994
=3D=3D LICENSE:
(The BSD 2-clause License)
Copyright (c) 2011 Jim Wise
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIB=
UTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
=2D-=20
Jim Wise
jwise@draga.com