Once again, a problem with my Befunge interpreter. I'm trying to
implement the ~ and & functions - get a character and a number,
respectively. My & function looks like this:
instructions["&"] = lambda { print "Number: "; stack.push
gets().strip.to_i}
But it complains about gets() being nil. as soon as the function is run.
Well, of course it is. It has let me type. Is there anyway to make it
halt?
Why does Ruby keep picking on me? Oh, wait. The principle of least
surprise - all programming languages infuriate me, therefore it would
surprise me least if Ruby did too.
Once again, a problem with my Befunge interpreter. I'm trying to
implement the ~ and & functions - get a character and a number,
respectively. My & function looks like this:
instructions["&"] = lambda { print "Number: "; stack.push
gets().strip.to_i}
But it complains about gets() being nil. as soon as the function is run.
Well, of course it is. It has let me type. Is there anyway to make it
halt?
--
-----------------------------------------------------------
Tomas Pospisek http://sourcepole.com - Linux & Open Source Solutions
-----------------------------------------------------------
If Ruby is invoked in this fashion
ruby myprog.rb myfile
then gets reads from the file.
You need
$stdin.gets
···
On Dec 5, 4:30 pm, Peter Bunyan <peter.bun...@gmail.com> wrote:
Once again, a problem with my Befunge interpreter. I'm trying to
implement the ~ and & functions - get a character and a number,
respectively. My & function looks like this:
instructions["&"] = lambda { print "Number: "; stack.push
gets().strip.to_i}
But it complains about gets() being nil. as soon as the function is run.
Well, of course it is. It has let me type. Is there anyway to make it
halt?
So I wonder: what in your code that you are _not_ showing us is messing you up?
Regards, Morton
···
On Dec 5, 2007, at 5:52 PM, Tomas Pospisek's Mailing Lists wrote:
On Thu, 6 Dec 2007, Peter Bunyan wrote:
Once again, a problem with my Befunge interpreter. I'm trying to
implement the ~ and & functions - get a character and a number,
respectively. My & function looks like this:
instructions["&"] = lambda { print "Number: "; stack.push
gets().strip.to_i}
But it complains about gets() being nil. as soon as the function is run.
Well, of course it is. It has let me type. Is there anyway to make it
halt?