[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01754] Re: Perl => Ruby

From: "Dat Nguyen" <thucdat@...>
Date: 2000-03-06 15:49:28 UTC
List: ruby-talk #1754
OZAWA -Crouton- Sakuro already instructed me how to do it as follows:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Interactive one already exists in the official dists.  Just get any
binary/(or get the source and make), then try the below:

$ ruby -r 'irb/main' -e IRB.start [ENTER]
irb(main):001:0> def fib(x)
irb(main):002:1>   x < 2 ? 1 : fib(x-1) + fib(x-2)
irb(main):003:1> end
nil
irb(main):004:0> fib(3)
3
irb(main):005:0> fib(5)
8
irb(main):006:0> exit
$
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

It works great on my Linux box, no need to download anything extra.
However, as seen from the 'irb/main', it's not applicable for my WIN/NT. 
That's why I am trying to work around, since I don't have any tool to 
recompile Ruby on my WIN/NT.

Regards,
Dat

>From: Dave Thomas <Dave@thomases.com>
>Reply-To: ruby-talk@netlab.co.jp
>To: ruby-talk@netlab.co.jp (ruby-talk ML)
>Subject: [ruby-talk:01753] Re: Perl => Ruby
>Date: 06 Mar 2000 08:24:18 -0600
>
>"Dat Nguyen" <thucdat@hotmail.com> writes:
>
> > How to write the following Perl code in Ruby:
> >
> >                     while (<>) { eval; print $@; }
>
>It isn't as concise, as Ruby returns eval errors as exceptions:
>
>      while gets
>        begin
>          eval $_
>        rescue
>          puts $!
>        end
>      end
>
>You might also want to have a look at sample/eval.rb in the
>distribution. If you want an interactive way to execute Ruby, you
>might also want to check out 'irb'.
>
>Regards
>
>Dave

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

In This Thread

Prev Next