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
| g (x:xs) (y:ys) | |
| | x==y = g xs ys | |
| | otherwise = (y:ys) | |
| g [] ys = ys | |
| g _ [] = [] | |
| g [] [] = [] |
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 CPP #-} | |
| {-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math#-} | |
| {-# OPTIONS_GHC -funbox-strict-fields -fexcess-precision -monly-3-regs #-} | |
| {-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} | |
| {-# LANGUAGE NoMonomorphismRestriction #-} | |
| module Main where | |
| import Control.Applicative | |
| import Data.List | |
| import Data.Function (on) | |
| import Text.Printf |
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 CPP #-} | |
| {-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math#-} | |
| {-# OPTIONS_GHC -funbox-strict-fields -fexcess-precision -monly-3-regs #-} | |
| {-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} | |
| {-# LANGUAGE NoMonomorphismRestriction #-} | |
| module Main where | |
| import Control.Applicative | |
| import Data.List | |
| import Data.Function (on) | |
| import Text.Printf |
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 Lcs where | |
| import Data.Array | |
| makeTable xs ys = tbl | |
| where | |
| n = length xs | |
| m = length ys | |
| tbl :: Array (Int,Int) Integer | |
| tbl = array ((0,0),(n,m)) [let x = if (xs!!(i-1)) == (ys!!(j-1)) then 1 else 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 LevenshteinDistance where | |
| import Data.Array | |
| levenshteinDistance xs ys = tbl!(n,m) | |
| where | |
| n = length xs | |
| m = length ys | |
| tbl = listArray ((0,0),(n,m)) [ let x = if xs!!(i-1) == ys!!(j-1) then 0 else 1 | |
| in | |
| if i==0 then j |
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
| trace a b = unsafePerformIO $ print a >> return b |
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 Control.Applicative | |
| import Data.List | |
| import Data.Maybe | |
| import Data.Function (on) | |
| import Text.Printf | |
| splitBy :: (a -> Bool) -> [a] -> [[a]] | |
| splitBy p [] = [] | |
| splitBy p xs = a : (splitBy p $ dropWhile p $ b) |
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 Control.Applicative | |
| import Data.List | |
| import Data.Maybe | |
| import Data.Function (on) | |
| import Text.Printf | |
| splitBy :: (a -> Bool) -> [a] -> [[a]] | |
| splitBy p [] = [] | |
| splitBy p xs = a : (splitBy p $ dropWhile p $ b) |
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
| {-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -cpp #-} | |
| module Main where | |
| import Data.List (zipWith4, foldl', genericLength) | |
| import Control.Monad | |
| import Data.Array | |
| import Control.Applicative | |
| import Text.Printf | |
| applyDP edits edge xs y = applyDP' | |
| where |
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
| {-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -cpp #-} | |
| module Main where | |
| import Data.List (zipWith4, foldl', genericLength) | |
| import Control.Monad | |
| import Data.Array | |
| import Control.Applicative | |
| import Text.Printf | |
| applyDP edits edge xs y = applyDP' | |
| where |