Created
November 13, 2018 20:59
-
-
Save bkyrlach/514586abb7882ffc749e6dbd7acc7e17 to your computer and use it in GitHub Desktop.
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
| module Intro where | |
| import Data.Char (toUpper) | |
| x = 3 | |
| greeting = "Hello" | |
| three :: () -> Int | |
| three _ = 3 | |
| y = three () | |
| square (n) = n * n | |
| greet name = greeting ++ ", " ++ name ++ "!" | |
| add (x,y) = x + y | |
| mult (x,y) = x * y | |
| sumit ([]) = 0 | |
| sumit ((h:t)) = add (h,sumit (t)) | |
| prod ([]) = 1 | |
| prod ((h:t)) = mult (h,prod (t)) | |
| flerf (base, f, []) = base | |
| flerf (base, f, (h:t)) = f (h, flerf (base, f, t)) | |
| power (xs) = flerf (1, (\(x,y) -> x^y), xs) | |
| add' :: Int -> Int -> Int | |
| add' x y = x + y | |
| chickenCurry :: ((a,b) -> c) -> a -> b -> c | |
| chickenCurry f = (\a -> \b -> f (a,b)) | |
| add'' = chickenCurry add | |
| flerf' base f [] = base | |
| flerf' base f (h:t) = f h $ flerf' base f t | |
| power' = flerf' 1 (^) | |
| mapit f [] = [] | |
| mapit f (h:t) = (f h):(mapit f t) | |
| shout s = mapit toUpper s | |
| shoutAGreeting = shout . greet | |
| greetByShoutingName = greet . shout | |
| data Color = Red | Green | Blue | |
| colorToString Red = "Red" | |
| colorToString Green = "Green" | |
| colorToString Blue = "Blue" | |
| data Color' = Red' | Green' | Blue' deriving (Show) | |
| data Tree a = | |
| | Branch Tree a Tree | |
| | Leaf | |
| deriving (Show) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment