Skip to content

Instantly share code, notes, and snippets.

@Raynes
Created November 14, 2009 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynes/234337 to your computer and use it in GitHub Desktop.
Save Raynes/234337 to your computer and use it in GitHub Desktop.
module Main where
import Control.Monad
import Data.List
import Data.Char
import System.IO
getSecondWord = head . tail . words
getLastWord = last . words
myReverse = foldl (flip (:)) []
lastButOne = head . reverse . init
data Meow a = Meow a
deriving (Show)
splitDigits :: String -> [Int]
splitDigits = map digitToInt
addNum :: Int -> Int
addNum = foldl' (+) 0 . splitDigits . show
myLast :: [a] -> a
myLast = head . reverse
data Tree a = Node a (Tree a) (Tree a)
| Empty
deriving (Show)
ghci> let x = Node "Meow" (Node "Hello" Empty Empty) (Node "Hai!" Empty Empty)
ghci> x
Node "Meow" (Node "Hello" Empty Empty) (Node "Hai!" Empty Empty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment