GolfScript
On Linux
Install Ruby (almost certainly packaged with your distro) and then download the official interpreter.
On Windows
I've successfully used IronRuby to run a tweaked version of the interpreter. Patch:
--- golfscript.rb.orig
+++ golfscript.rb
@@ -272,7 +272,8 @@
factory(to_s.inspect)
end
def to_s
- @val.pack('C*')
+ # Workaround for IronRuby bug, thanks to w0lf
+ ''[email protected]('C*')
end
def class_id; 2; end
def coerce(b)
@@ -389,8 +390,16 @@
end
include Comparable
end
-code=gets(nil)||''
-$_=$stdin.isatty ? '' : $stdin.read
+
+# IronRuby's implementation of gets is buggy
+code=File.read(ARGV[0])
+
+# PowerShell's handling of stdin will drive you nuts
+$_=''
+if (ARGV[1])
+ $_=File.read(ARGV[1])
+end
+
$stack = [Gstring.new($_)]
$var_lookup={}
Note that the tweaks include taking input from a second file provided as an argument instead of from stdin, because I found that easier. I also set up an alias in my PowerShell profile:
function golfscript {
&"c:\Program Files (x86)\IronRuby 1.1\bin\ir64.exe" d:\stuff\golfscript.rb $args
}