Skip to content

Instantly share code, notes, and snippets.

View chaoxu's full-sized avatar
😀

Chao Xu chaoxu

😀
  • University of Electronic Science and Technology of China
  • Chengdu, Sichuan, China
View GitHub Profile
@chaoxu
chaoxu / lcs.hs
Created December 15, 2012 06:24 — forked from srayuws/lcsIO.hs
--ST Monad instead!
lcs :: (Eq a) => [a] -> [a] -> [a]
lcs s' t' = reverse $ build n m
where
a = runST $ do
b <- newArray ((0,0),(n,m)) 0
mapM_ (f b) $ range ((0,0),(n,m))
unsafeFreeze b
n = length s'
m = length t'