Re: [Haskell-cafe] None brute-force BWT algorithm

2011-06-23 Thread larry.liuxinyu
T into a function, just like what we've done in KMP implementation in FP way. Does such solution exist? Regards. -- Larry, LIU Xinyu https://github.com/liuxinyu95/AlgoXY On Friday, June 24, 2011 6:50:46 AM UTC+8, Henning Thielemann wrote: On Wed, 22 Jun 2011, larry.liuxinyu wrote: Hi

[Haskell-cafe] None brute-force BWT algorithm

2011-06-22 Thread larry.liuxinyu
Hi, I read a previous thread about BWT implementation in Haskell: http://www.mail-archive.com/haskell-cafe@haskell.org/msg25609.html and http://sambangu.blogspot.com/2007/01/burrows-wheeler-transform-in-haskell They are all in a `brute-force' way, that is implement based on Burrows-Wheeler's

[Haskell-cafe] AVL Tree in a pattern matching way

2011-05-11 Thread larry.liuxinyu
Hi, I browsed the current AVL tree implementation in Hackage http://hackage.haskell.org/packages/archive/AvlTree/4.2/doc/html/src/Data-Tree-AVL-Push.html AVL tree denote the different of height from right sub-tree to left sub-tree as delta, to keep the balance, abs(delta)=1 is kept as invariant.

Re: [Haskell-cafe] QuickCheck, (Ord a)= [a] - Property problem

2011-04-22 Thread larry.liuxinyu
(prop_foo::[Int]-Property) Cheers. -- Larry. On Apr 22, 5:56 am, Nick Smallbone nick.smallb...@gmail.com wrote: larry.liuxinyu liuxiny...@gmail.com writes: Somebody told me that: Eduard Sergeev • BTW, more recent QuickCheck (from Haskell Platform 2011.2.0.X - contains QuickCheck-2.4.0.1

[Haskell-cafe] QuickCheck, (Ord a)= [a] - Property problem

2011-04-20 Thread larry.liuxinyu
Hi, I found there is similar question as: http://groups.google.com/group/haskell-cafe/browse_thread/thread/7439262e9ac80dd2/91ca18e11ff00649?lnk=gstq=QuickCheck+Ord+a#91ca18e11ff00649 I am still think it's very strange. For example: prop_foo :: (Ord a) = [a] - Property prop_foo xs = not (null

Re: [Haskell-cafe] QuickCheck, (Ord a)= [a] - Property problem

2011-04-20 Thread larry.liuxinyu
! Falsifiable (after 3 tests and 2 shrinks): [0,1] False -- Larry On Apr 20, 11:36 pm, Nick Smallbone nick.smallb...@gmail.com wrote: larry.liuxinyu liuxiny...@gmail.com writes: prop_foo :: (Ord a) = [a] - Property prop_foo xs = not (null xs) == maximum xs == minimum xs This is an extreme case

[Haskell-cafe] Haskell KMP(Knuth-Morris-Pratt) algorithm

2011-03-03 Thread larry.liuxinyu
Hi, I read about some KMP implementation in Haskell including: [1] Richard Bird. ``Pearls of Functional algorithm design'' [2] http://twan.home.fmf.nl/blog/haskell/Knuth-Morris-Pratt-in-Haskell.details [3] http://www.haskell.org/haskellwiki/Runtime_compilation [4] LazyString version [1]

Re: [Haskell-cafe] Haskell KMP(Knuth-Morris-Pratt) algorithm

2011-03-03 Thread larry.liuxinyu
then (succs, ns++[n]) else (succs, ns) | otherwise = tr (fails, ns) (x, n) In the program, tr is the transfer function applied to the state tree. And build function is used to build the automaton. Best regards. -- LIU On Mar 3, 5:25 pm, larry.liuxinyu liuxiny...@gmail.com wrote: Hi, I

[Haskell-cafe] Draw K-ary forest in dot script

2011-01-09 Thread larry.liuxinyu
Hi, I wrote a Haskell program to parse K-ary forest and convert it to dot script (Graphviz). Here is the literate program. -- First is some stuff imported: module Main where import System.Environment (getArgs) import Text.ParserCombinators.Parsec import Control.Monad (mapM_) import Data.List

[Haskell-cafe] Fibonacci Heap without using Monad

2010-12-30 Thread larry.liuxinyu
Hi, I checked the current Fibonacci Queue in Hackage DB: http://hackage.haskell.org/packages/archive/pqueue-mtl/1.0.7/doc/html/src/Data-Queue-FibQueue.html#FQueue And a history email for Okasaki in 1995: http://darcs.haskell.org/nofib/gc/fibheaps/orig The hardest part is how to consolidate all

Re: [Haskell-cafe] Fibonacci Heap without using Monad

2010-12-30 Thread larry.liuxinyu
Hi, In CLRS, there are algorithms about DECREASE-KEY and DELETE-NODE. However, in the Functional approach, I didn't find corresponding solution. One approach may just mark the node as `deleted' and when pops the top element from the heap, we repeat it until find a unmarked node. -- LIU

Re: [Haskell-cafe] Fibonacci Heap without using Monad

2010-12-30 Thread larry.liuxinyu
Hi, Sorry for there is a bug in my previous post. The example consolidate function for number should be like this: consolidate xs = foldl meld [] xs where meld [] x = [x] meld (x':xs) x | x == x' = meld xs (x+x') | x x' = x:x':xs | otherwise = x':

[Haskell-cafe] Re: Splay tree in a pattern matching way

2010-10-24 Thread larry.liuxinyu
Hi, I just tried a smoke test case, seems the tree is balanced enough: import System.Random lookup :: (Ord a) = STree a - a - STree a lookup E _ = E lookup t@(Node l x r) y | x == y= t | x y = splay (Node (lookup l y) x r) y | otherwise = splay (Node l x (lookup r y)) y