module Lesson1 where
import Prelude hiding (not, (&&), (||), swap)
one :: Int
one = 1
inc :: Double -> Double
inc x = x + 1
add :: Double -> Double -> Double
add x y = x + y
infixl 6 `add`
add' :: (Double, Double) -> (Double, Double) -> (Double, Double)
add' (x, y) (z, s) = (x + z, y + s)
not :: Bool -> Bool
not False = True
not True = False
(&&) :: Bool -> Bool -> Bool
(&&) True True = True
(&&) _ _ = False
(&&&) :: Bool -> Bool -> Bool -> Bool
(&&&) True True True = True
(&&&) _ _ _ = False
(||) :: Bool -> Bool -> Bool
(||) False False = False
(||) _ _ = True
(-->) :: Bool -> Bool -> Bool
(-->) True False = False
(-->) _ _ = True
rnl :: Char -> Char
rnl '\n' = ' '
rnl x = x
rnlc :: Char -> Char -> Char
rnlc '\n' x = x
rnlc y _ = y
iet :: Int -> (Int, Bool)
iet x = (x, even(x))
swap :: (a, b) -> (b, a)
swap (a, b) = (b, a)
triplicate :: a -> (a, a, a)
triplicate a = (a, a, a)
-- Guards
isOne :: Int -> Bool
isOne x
| x == 1 = True
| otherwise = False
-- Adhoc polimorfizmus
-- isPrime :: Integral a => a -> Bool
-- .....
fact :: Int -> Int
fact 0 = 1
fact n = n * fact (n-1)