Skip to main content
1 of 4

Bash w/Haskell, 275

echo 'data E=N Integer|E:+E|E:-E|E:*E|E:/E
instance Num E where fromInteger=N;a+b=a:+b;a-b=a:-b;a*b=a:*b
instance Fractional E where a/b=a:/b
d a o b=unwords[p a,p b,o]
p(N n)=show n
p(a:+b)=d a"+"b
p(a:-b)=d a"-"b
p(a:*b)=d a"*"b
p(a:/b)=d a"/"b
main=putStr.p$'$*|runghc 2>w

Pity, it's longer than the C solution though I was almost as lazy as @Geoff with the bc one...

Takes input as command-line parameters. A file w with some ghc warning messages will be created, if you don't like this change to runghc 2>/dev/null.