On 5 February 2012 05:23, Qi Qi <qiqi...@gmail.com> wrote: > Hello, > > I have a question;how can I print out the intermediate number lists in a > mergesort recursive function like the following one.
You can use the (completely evil and shouldn't be used in production code) Debug.Trace module. > > merge [] ys = ys > merge xs [] = xs > merge (x:xs) (y:ys) = if x <= y > then x : merge xs (y:ys) > else y : merge (x:xs) ys > > mergesort [] = [] > mergesort [x] = [x] > mergesort xs = let (as, bs) = splitAt (length xs `quot` 2) xs > in merge (mergesort as) (mergesort bs) > > main = do > print $ mergesort [5,4,3,2,1] > > > In the main function, it only prints out the final number list. But I'd > like to print out the number lists in every recursive level. How can I > do that? Thanks. > > > -- > Qi Qi > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe