[Haskell-beginners] Add parenthesis to Sin/Cos expressions

Imants Cekusins imantc at gmail.com
Wed Nov 4 09:21:18 UTC 2015


> a function that is supposed to add parenthesis to sin/cos expressions.
a) Sin 5 + 3        ->    Sin(5) + 3
b) Sin Cos (5+3)   ->    Sin (Cos(5+3))
c) Sin Cos 5 * 3   ->    Sin(Cos(5)) * 3

are you looking for textual representation or actual Haskell code which runs?
if actual code, these examples may be re-written like this:
a) sin 5 + 3
b) sin $ cos $ 5 + 3
c) sin (cos 5) * 3


More information about the Beginners mailing list