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 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
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 (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
{-# 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 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
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
module Main where | |
import Data.Ratio | |
import Data.Tree | |
data Label = Label | |
{ f1 :: (Rational -> Rational) | |
, accept :: (Rational -> 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 OverloadedStrings #-} | |
import Codec.Archive.Zip | |
import Data.ByteString.Lazy (getContents, putStrLn) | |
import Data.ByteString.Lazy.Char8 (ByteString) | |
import Prelude hiding (getContents, putStrLn) | |
import Data.Maybe (maybe) | |
import System.Environment (getArgs) | |
import System.Exit (exitFailure) | |
main = do filePath <- getArgs >>= parse |
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
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
''' | |
convert Microsoft Word 2007 docx files to wiki markup files | |
''' | |
from lxml import etree | |
import zipfile | |
import string | |
import sys |