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
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Applicative | |
import Control.Exception | |
import Control.Monad | |
import Data.Char | |
import Data.List | |
import Data.Maybe | |
import Data.ByteString.Char8 (ByteString) | |
import qualified Data.ByteString.Char8 as C | |
import Prelude hiding (readFile) |
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 Control.Monad (forM_) | |
import qualified Data.DList as DL | |
import System.Environment (getArgs,getProgName) | |
import System.Exit (exitSuccess) | |
data CSVState = OutsideQuote | InsideQuote | AfterQuote | |
listFromCSV :: String | |
→ [String] | |
listFromCSV = toResult ∘ foldl parseChar (OutsideQuote,DL.empty,DL.empty) |
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
{-# LANGUAGE InstanceSigs #-} | |
module Data.TwoThreeTree where | |
import Control.Applicative | |
import Data.Foldable | |
import Data.Traversable | |
import Prelude hiding (foldr) | |
data Tree23 k = Leaf |
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
-- To build just copy this and convexhull.cabal somewhere | |
-- and then run cabal build | |
-- | |
-- Usage Example: | |
-- > ./dist/build/viewConvexHull/viewConvexHull plot.pdf 1,10 10,5 4,6 7,9 20,1 4,2 5,6 8,2 3,9 | |
-- | |
-- this creates a pdf file called plot.pdf with the plot in the current directory | |
module Main where | |
import Control.Arrow |
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.Colour.RGBSpace.HSV (RGB, hsv) | |
nextColor :: (RealFrac a) => a -> a -> a -> (RGB a,a) | |
nextColor h s v = let h' = (h + golden_ratio_conjugate) % 360 | |
in (hsv h' s v,h') | |
where golden_ratio_conjugate = 222.4922359499622 -- 0.618033988749895 * 360 | |
dividend % divisor = dividend - divisor * | |
(fromIntegral $ floor (dividend/divisor)) | |
goldenColors :: (RealFrac a) => a -> a -> a -> [RGB a] |
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 Control.Monad (unless) | |
import Prelude hiding (catch) | |
import System.IO (isEOF) | |
prependLineNums :: Int -> IO () | |
prependLineNums n = isEOF >>= flip unless prependLineNum | |
where prependLineNum = getLine >>= putStrLn . (++) (padTo 5 $ show n) | |
>> prependLineNums (n+1) | |
padTo c s = case c `compare` length s of | |
GT -> s ++ replicate (c - length s) ' ' |
NewerOlder