This file contains 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
-- To run, you will need the Haskell Platform | |
-- $> runhaskell flatten.hs | |
data Node a = Single a | |
| Many [Node a] | |
deriving Show | |
flatten :: [Node a] -> [a] | |
flatten [] = [] | |
flatten ((Single v):xs) = v : flatten xs | |
flatten ((Many xs):xs') = flatten xs ++ flatten xs' |
This file contains 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
main = putStrLn $ unlines $ map (`replicate` '*') [1..5] |
This file contains 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 Prelude hiding (tail) | |
import Data.List (find) | |
import Control.Monad.State (State,put,get,runState) | |
type VarName = String | |
type Variable a = (VarName, a) | |
type Stack a = [Variable a] | |
test :: State (Stack String) String | |
test = do |
This file contains 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 qualified Data.List as L | |
data Direction = Left' | Straight' | Right' deriving (Show, Read, Eq) | |
data Point = Point Double Double deriving (Show, Read, Eq) | |
data LineSegment = LineSegment Point Point deriving (Show, Read) | |
graham :: [Point] -> [Point] | |
graham = graham' . sort |