Fix Total004 test

Names in Data.List clashed
This commit is contained in:
Edwin Brady 2019-07-06 15:55:47 +01:00
parent 62382dcd96
commit fc224b1450
3 changed files with 14 additions and 14 deletions

View File

@ -111,17 +111,17 @@ qsort' (x :: xs)
partition : a -> List a -> (List a, List a) partition : a -> List a -> (List a, List a)
partition x xs = (filter (< x) xs, filter (>= x) xs) partition x xs = (filter (< x) xs, filter (>= x) xs)
sorted : Ord a => List a -> Bool mySorted : Ord a => List a -> Bool
sorted [] = True mySorted [] = True
sorted (x::xs) = mySorted (x::xs) =
case xs of case xs of
Nil => True Nil => True
(y::ys) => x <= y && sorted (y::ys) (y::ys) => x <= y && mySorted (y::ys)
mergeBy : (a -> a -> Ordering) -> List a -> List a -> List a myMergeBy : (a -> a -> Ordering) -> List a -> List a -> List a
mergeBy order [] right = right myMergeBy order [] right = right
mergeBy order left [] = left myMergeBy order left [] = left
mergeBy order (x::xs) (y::ys) = myMergeBy order (x::xs) (y::ys) =
case order x y of case order x y of
LT => x :: mergeBy order xs (y::ys) LT => x :: myMergeBy order xs (y::ys)
_ => y :: mergeBy order (x::xs) ys _ => y :: myMergeBy order (x::xs) ys

View File

@ -15,6 +15,6 @@ Main> Main.size is total
Main> Main.qsortBad is not terminating due to recursive path Main.qsortBad -> Main.qsortBad Main> Main.qsortBad is not terminating due to recursive path Main.qsortBad -> Main.qsortBad
Main> Main.qsort is total Main> Main.qsort is total
Main> Main.qsort' is total Main> Main.qsort' is total
Main> Main.sorted is total Main> Main.mySorted is total
Main> Main.mergeBy is total Main> Main.myMergeBy is total
Main> Bye for now! Main> Bye for now!

View File

@ -13,6 +13,6 @@
:total qsortBad :total qsortBad
:total qsort :total qsort
:total qsort' :total qsort'
:total sorted :total mySorted
:total mergeBy :total myMergeBy
:q :q