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 Main where | |
import Data.Ratio | |
import Data.Tree | |
data Label = Label | |
{ f1 :: (Rational -> Rational) | |
, accept :: Bool | |
, f2 :: (Rational -> Rational) |
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 ExistentialQuantification #-} | |
module Main where | |
import Debug.Trace(traceShow) | |
import System.Environment | |
import Text.ParserCombinators.Parsec hiding (spaces) | |
import Control.Applicative ((<$>)) | |
import Control.Monad.Error | |
import Data.IORef | |
import IO hiding (try) |
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 BangPatterns, ViewPatterns #-} | |
import System.Environment (getArgs) | |
import Control.Monad | |
import Control.Monad.ST | |
import Data.STRef | |
import GHC.Int | |
fib1 :: Int -> Integer | |
fib1 n = fibs !! n | |
where fibs = 1 : 1 : zipWith (+) fibs (tail fibs) |
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 BangPatterns #-} | |
module Main (fib1, fib2, fib3, fib4, main) where | |
import Control.Monad | |
import Control.Monad.ST | |
import Data.STRef | |
import Data.List (transpose) | |
import Criterion.Main | |
fib1 :: Int -> Integer | |
fib1 n = fst $ fib' n |
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 RSA where | |
-- extendedGcd(a,b) = (x,y), such that a*x + b*y = gcd(a,b) | |
extendedGcd :: Integral a => (a, a) -> (a, a) | |
extendedGcd (a, b) = if b == 0 then (1, 0) else (x, y) | |
where | |
(q, r) = divMod a b | |
(s, t) = extendedGcd (b, r) | |
(x, y) = (t, s - q * t) |
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 BangPatterns #-} | |
module Main where | |
import Data.List (transpose) | |
import Criterion.Main | |
naiveFib, cachedFib, cachedFib', tailrFib, tailrFib', matrixFib | |
:: Integer -> Integer | |
naiveFib 0 = 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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
import Data.Aeson | |
import qualified Data.ByteString.Char8 as BS | |
import qualified Data.ByteString.Lazy.Char8 as BSL | |
import Data.ByteString.Lazy (toChunks) | |
import Data.List | |
import Data.Maybe | |
import Data.Typeable (Typeable) |
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 TypeFamilies #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
module Indexable where | |
import qualified Data.Aeson as A | |
import qualified Data.HashMap.Strict as HM | |
import qualified Data.Map as M | |
import qualified Data.Vector as V | |
import Data.Text (Text, unpack) |
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 Church where | |
import Prelude ((.), ($), id, fst, undefined, length) | |
zero f = id | |
inc n f = f . n f | |
one f = f | |
two f = f . f | |
three f = f . f . f |
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 Main where | |
import Data.Char (digitToInt) | |
sort :: (Ord a) => [a] -> [a] | |
sort [] = [] | |
sort (x:xs) = sort smaller ++ [x] ++ sort greater | |
where | |
smaller = filter (not.(> x)) xs | |
greater = filter (> x) xs |