postfix to infix by yowa

#!ruby -pl
a=[]
scan(/./){|c|a<<(c>'0'?[-1,c]:(e,x=a.pop
d,y=a.pop
[n="/*-+".index(c),[d/2<=n/2?y:"(#{y})",c,e<n||e*n%8==1?x:"(#{x})"]]))}
$_=a[0][1]

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top