[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Poor reverse polish calculator



I wanted to try to implement a reverse polish calculator in 80
characters, but in the end I couldn't get it any smaller than 120:

while(<>){for(split' '){if("+-*/"!~/([$_])/){push@k,$_;next;}
($O,$Z)=splice@k,-2;push@k,eval"$O$1$Z";}print pop@k,"\n";}

I know this code sucks and doesn't have any clever hacks in it, but
can anyone write something functionally similar in eighty?
-- 
Alisdair McDiarmid                    <http://wasters.org/pubkey.asc>

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe