No title

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mergesort'merge :: (Ord a) => [a] -> [a] -> [a]
mergesort'merge [] xs = xs
mergesort'merge xs [] = xs
mergesort'merge (x:xs) (y:ys)
    | (x < y) = x:mergesort'merge xs (y:ys)
    | otherwise = y:mergesort'merge (x:xs) ys
 
mergesort'splitinhalf :: [a] -> ([a], [a])
mergesort'splitinhalf xs = (take n xs, drop n xs)
    where n = (length xs) `div` 2 
 
mergesort :: (Ord a) => [a] -> [a]
mergesort xs 
    | (length xs) > 1 = mergesort'merge (mergesort ls) (mergesort rs)
    | otherwise = xs
    where (ls, rs) = mergesort'splitinhalf xs
2:1: Warning: Use camelCase
Found:
mergesort'merge [] xs = ...
Why not:
mergesortMerge [] xs = ...
5:7: Warning: Redundant bracket
Found:
(x < y)
Why not:
x < y
9:1: Warning: Use camelCase
Found:
mergesort'splitinhalf xs = ...
Why not:
mergesortSplitinhalf xs = ...
10:15: Warning: Redundant bracket
Found:
(length xs) `div` 2
Why not:
length xs `div` 2
14:7: Warning: Redundant bracket
Found:
(length xs) > 1
Why not:
length xs > 1