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
| myNot :: Bool -> Bool | |
| myNot True = False | |
| myNot _ = True | |
| myAnd :: Bool -> Bool -> Bool | |
| myAnd True b = b | |
| myAnd _ _ = False | |
| myOr :: Bool -> Bool -> Bool | |
| myOr False b = b |
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
| isLeap :: Int -> Bool | |
| isLeap x | |
| | canBeDividedBy 4 && not (canBeDividedBy 100) = True | |
| | canBeDividedBy 400 = True | |
| | otherwise = False | |
| where | |
| canBeDividedBy y = x `mod` y == 0 |
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
| fizzBuzz :: Int -> String | |
| fizzBuzz x | |
| | fizz && buzz = "FizzBuzz" | |
| | fizz = "Fizz" | |
| | buzz = "Buzz" | |
| | otherwise = show x | |
| where | |
| fizz = x `mod` 3 == 0 | |
| buzz = x `mod` 5 == 0 |
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
| analysisLine :: String -> String | |
| analysisLine [] = "empty" | |
| analysisLine (_:[]) = "a character" | |
| analysisLine xs | |
| | last xs == '.' = "a sentence" | |
| | ' ' `elem` xs = "some words" | |
| | otherwise = "a word" |
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
| import Data.Char | |
| charToInt :: Char -> Int | |
| charToInt c | |
| | isLower c = ord c - ord 'a' | |
| | isUpper c = ord c - ord 'A' + 26 | |
| | otherwise = ord c | |
| intToChar :: Int -> Char | |
| intToChar x |
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
| charName :: Char -> String | |
| charName 'a' = "Albert" | |
| charName 'b' = "Broseph" | |
| charName 'c' = "Cecil" | |
| charName _ = "Special Others" |
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
| myLength :: [a] -> Int | |
| myLength [] = 0 | |
| myLength (_:xs) = 1 + myLength xs |
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
| mySum :: [Int] -> Int | |
| mySum [] = 0 | |
| mySum (x:xs) = x + mySum xs | |
| myProduct :: [Int] -> Int | |
| myProduct [] = 1 | |
| myProduct (x:xs) = x * myProduct xs |
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
| oddEven :: [Int] -> ([Int], [Int]) | |
| oddEven [] = ([], []) | |
| oddEven (x:xs) | |
| | odd x = connectTuple ([x], []) $ oddEven xs | |
| | otherwise = connectTuple ([], [x]) $ oddEven xs | |
| where | |
| connectTuple :: ([a], [b]) -> ([a], [b]) -> ([a], [b]) | |
| connectTuple (x1, y1) (x2, y2) = (x1 ++ x2, y1 ++ y2) |
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
| gp :: Num a => a -> a -> [a] | |
| gp first ratio = [first] ++ gp (first * ratio) ratio |
OlderNewer