CALC fixed by nn

System.in.eachLine{s=it.replaceAll(/[*+-]/,' $0 ')
v=0
c='+'
s.split().each{u->c=c?{w->(v=c<'+'?v*w:c<'-'?v+w:v-w)*0}(u.toLong()):u}
println s+' = '+v}

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

download

return to the top page