Last active
August 29, 2015 14:05
-
-
Save dskecse/08fb2ce90663a820abbf to your computer and use it in GitHub Desktop.
Implementations of math function in Haskell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | ln (abs(sin(x))), if x > 5 | |
-- y = | x^2 + a^2, if x <= 5 and a <= 3 | |
-- | x / a + 7.8*a, if x <= 5 and a > 3 | |
y x a = if x > 5 | |
then log (abs (sin (x))) | |
else | |
if x <= 5 && a <= 3 | |
then x^2 + a^2 | |
else x / a + 7.8 * a | |
y' x a = case x > 5 of | |
True -> log (abs (sin (x))) | |
False -> case x <= 5 && a <= 3 of | |
True -> x^2 + a^2 | |
False -> x / a + 7.8 * a | |
-- guards | |
y'' x a | x > 5 = log (abs (sin (x))) | |
| x <= 5 && a <= 3 = x^2 + a^2 | |
| otherwise = x / a + 7.8 * a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment