![]() |
|
#!/usr/local/bin/ruby
Then you have to make the file pi.rb executable, using the command % chmod +x pi.rb, and you can invoke Ruby to run the program by just typing its name: pi.rb, at the Unix % prompt. So now download pi.rb, make it executable, and execute it.
The download gives you everything, including the C source for Ruby.
% ruby for i in ['fee', 'fi', 'fo', 'fum'] print i, ' ' end (Ctrl-D typed) fee fi fo fum
% ruby eval.rb ruby> for i in ['fee', 'fi', 'fo', 'fum'] ruby| print i, ' ' ruby| end fee fi fo fum ["fee", "fi", "fo", "fum"] ruby> puts "th-th-th-that\'s-all-folks" th-th-th-that's-all-folks nil ruby>(Ctrl-D typed) %
% irb irb(main):001:0> a = 1+ irb(main):002:0* 2*3/ irb(main):003:0* 4%5 => 2 irb(main):004:0> 2+2 => 4 irb(main):005:0> def test irb(main):006:1> puts "Hello, world!" irb(main):007:1> end => nil irb(main):008:0> test Hello, world! => nil irb(main):009:0> exit %
% ruby -r debug pi.rb Debug.rb Emacs support available. pi.rb:2:k, a, b, a1, b1 = 2, 4, 1, 12, 4 (rdb:1) list 1-13 [1, 13] in pi.rb 1 => 2 k, a, b, a1, b1 = 2, 4, 1, 12, 4 3 loop do 4 p, q, k = k*k, 2*k+1, k+1 5 a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 6 d, d1 = a/b, a1/b1 7 while d == d1 8 print d 9 $stdout.flush 10 a, a1 = 10*(a%b), 10*(a1%b1) 11 d, d1 = a/b, a1/b1 12 end 13 end (rdb:1) b 4 Set breakpoint 1 at pi.rb:4 (rdb:1) c Breakpoint 1, toplevel at pi.rb:4 pi.rb:4: p, q, k = k*k, 2*k+1, k+1 (rdb:1) c 3Breakpoint 1, toplevel at pi.rb:4 pi.rb:4: p, q, k = k*k, 2*k+1, k+1 (rdb:1) c 1Breakpoint 1, toplevel at pi.rb:4 pi.rb:4: p, q, k = k*k, 2*k+1, k+1 (rdb:1) c Breakpoint 1, toplevel at pi.rb:4 pi.rb:4: p, q, k = k*k, 2*k+1, k+1 (rdb:1) c 4Breakpoint 1, toplevel at pi.rb:4 pi.rb:4: p, q, k = k*k, 2*k+1, k+1 (rdb:1) c 1Breakpoint 1, toplevel at pi.rb:4 pi.rb:4: p, q, k = k*k, 2*k+1, k+1 (rdb:1) exit %
Notice that as this program runs, after repeated c or cont commands (for "continue execution"), the program loops over and over to the breakpoint that was set at line 4. As it executes, it is outputting the initial digits of pi, shown in red above. (See Pi for runs of this program.)
They also said about the RCRs: "Make sure you vote too [for the RCRs]. But remember, the voting is only there to provide Matz with some indication of the interest in a given feature. This isn't a democracy, Matz still makes the final call."