This is a "continuation" from this post: How do I handle this data type
So now I have to print a "table" of numbers according to Numbers type in this format:
Positive Numbers:
1
4
16
Negative Numbers:
-3
-69
Null Numbers:
0
0
So I made this function:
printNum :: Numbers -> String
printNum (Numbers po ne nn)= "Positive Numbers: \n " ++ numP po ++
" \n Negative Numbers: \n " ++ numN ne ++
" \n Null Numbers: \n " ++ numZ nn
where
numP (p:ps) = show p ++ " \n " ++ numP ps
numP [] = []
numN (n:ns) = show n ++ " \n " ++ numN ns
numN [] = []
numZ (z:zs) = show z ++ " \n " ++ numZ zs
numZ [] = []
But the function is printing like this: "Positive Numbers: \n 1 \n 4 \n 16 \n \n Negative Numbers: \n -3 \n -69 \n \n Null Numbers: \n 0 \n 0 \n "