Well, if you want that in production, not for debugging purposes, you should
change the type signature of mergesort so that it uses some monad. Printing
requires IO monad; however, I would advise to collect all intermediate results
using Writer monad, and print them afterwards:
mergesort [] =
On 04/02/2012 08:46, MigMit wrote:
Well, if you want that in production, not for debugging purposes, you should
change the type signature of mergesort so that it uses some monad. Printing
requires IO monad; however, I would advise to collect all intermediate results
using Writer monad, and
* Steve Horne sh006d3...@blueyonder.co.uk [2012-02-04 11:54:44+]
On 04/02/2012 08:46, MigMit wrote:
Well, if you want that in production, not for debugging purposes, you should
change the type signature of mergesort so that it uses some monad. Printing
requires IO monad; however, I would
On Sat, Feb 04, 2012 at 12:23:07PM -0600, Qi Qi wrote:
Hello,
I have a question;how can I print out the intermediate number lists in a
mergesort recursive function like the following one.
merge [] ys = ys
merge xs [] = xs
merge (x:xs) (y:ys) = if x = y
then x :
Brilliant! That's what I was looking for. Thanks for all the replies.
Sometimes, I suspect that Haskell not only makes easier of the hard things for
imperative programming languages but also makes harder of some easy things.
Roman Cheplyaka r...@ro-che.info writes:
* Steve Horne
On Sun, Feb 05, 2012 at 01:17:31AM -0600, Qi Qi wrote:
Brilliant! That's what I was looking for. Thanks for all the replies.
Sometimes, I suspect that Haskell not only makes easier of the hard things for
imperative programming languages but also makes harder of some easy
things.
This is
Hello,
I have a question;how can I print out the intermediate number lists in a
mergesort recursive function like the following one.
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
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
You can use trace from Debug.Trace, change the code like this:
mergesort l = case trace l l of
[] - ...
[x] - ...
(x:xs) - ...
On Sun, Feb 5, 2012 at 2:23 AM, Qi Qi qiqi...@gmail.com wrote:
Hello,
I have a question;how can I print out the intermediate number lists in a
mergesort
Hi,
There is also this nice trick to use Debug.Trace:
merge xs ys | trace (show (xs,ys)) False = undefined -- add this as the
first case to merge
mergesort xs | trace (show xs) False = undefined -- and this as the first
case to mergesort
HTH,
Ozgur
10 matches
Mail list logo