matyr #3981(2007/11/13 22:13 GMT) [ JavaScript ] Rating2/2=1.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
function BF(code){ var s = '', o = { '>': 'm[p+=?]|=0;', '<': 'm[p-=?]|=0;', '+': 'm[p]+=?;', '-': 'm[p]-=?;', ',': 'm[p]=get().charCodeAt(0);', '.': 'put(c(m[p]));', '[': 'while(m[p]){', ']': '}' }; code.replace(/>+|<+|\++|-+|([,.[\]])/g, function($, _){ s += _ ? o[$] : o[$.charAt(0)].replace('?', $.length) }); return eval('0,function(get,put){var m=[0],p=0,c=String.fromCharCode;'+ s +'}'); } /// Rhinoで「hello world」のテスト /// BF('++++++++++[>+++++++>++++++++++>+++>+<<<<-]\ >++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.' )(function(){ return '?' }, function(c){ java.lang.System.out.print(c) }); /// WSHで「echo」のテスト /// //BF(',+[-.,+]')(function(){ return WSH.stdIn.read(1) }, function(c){ WSH.stdOut.write(c) });
Rating2/2=1.00-0+
[ reply ]
matyr
#3981()
[
JavaScript
]
Rating2/2=1.00
Rating2/2=1.00-0+
[ reply ]