You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
602 B
25 lines
602 B
module Part1
|
|
( parseFileString,
|
|
quickSort,
|
|
)
|
|
where
|
|
|
|
split :: [Int] -> ([Int], [Int])
|
|
split mylist = case mylist of
|
|
[] -> ([], [])
|
|
x : xs ->
|
|
let (evens, odds) = split xs
|
|
in (x : odds, evens)
|
|
|
|
parseFileString :: String -> ([Int], [Int])
|
|
parseFileString file_string = split parsed_word_list
|
|
where
|
|
parsed_word_list = [read word :: Int | word <- words file_string]
|
|
|
|
quickSort :: [Int] -> [Int]
|
|
quickSort [] = []
|
|
quickSort (x : xs) = smallerSorted ++ [x] ++ biggerSorted
|
|
where
|
|
smallerSorted = quickSort [a | a <- xs, a <= x]
|
|
biggerSorted = quickSort [a | a <- xs, a > x]
|