Pretty Fractions by jbb

#!ruby -n
a=[]
scan(/(\(.+?\)|\w+)(\/\(.+?\)|\/\w+)?(.)?/){y=$2.to_s.tr'()/',''
x=($2?$1.tr('()',''):$1).center y.size
(p=x.size).times{|i|a<<($2?[x[i],45,y.center(p)[i]]:[32,x[i],32])}
a<<[32,$3,32]if$3}
a.transpose.map{|l|l.map{|c|putc c}
puts}
puts

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

download

return to the top page