
I'm just getting started with Haskell. I've written the following simple program: module Med where -- lst = [5, 3, 7, 8, 0, 2, 4, 1, 6] lst = [7, 3, 1, 2, 0, 9, 8] numLessThan x = length([y | y <- lst, y < x]) numGreaterThan x = length([y | y <- lst, y > x]) median = [ x | x <- lst, numLessThan x == numGreaterThan x] I realize that this code isn't very robust. My questions are as follows: - I remember running this code with some values of lst (containing an odd number of unique integer values) and getting the wrong answer. Is that possible? I can't replicate the results because I don't remember what values of lst didn't work. - How can I add a line or two to display intermediate results (in order to debug the code if necessary)? I've tried adding putTraceMsg but I keep getting parse errors. I probably haven't fully assimilated the syntax of functional programming yet. Thanks.