From e18b27f43ac23689822d4aaaaa3e8d550e41017a Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Mon, 30 May 2022 20:36:38 +0900 Subject: v0.8.2-2 --- comparison/Haskell/bsort-20000.hs | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 comparison/Haskell/bsort-20000.hs (limited to 'comparison/Haskell/bsort-20000.hs') diff --git a/comparison/Haskell/bsort-20000.hs b/comparison/Haskell/bsort-20000.hs new file mode 100644 index 0000000..89ecfab --- /dev/null +++ b/comparison/Haskell/bsort-20000.hs @@ -0,0 +1,45 @@ +{- +https://gist.github.com/masquerade0324/68f4f3fd3ab897fbe1ad +http://files.farka.eu/pub/AC21007/lec5.pdf +-} + +import System.Random + +bs xs 0 = xs +bs (x:y:ys) n = + if x IO([Int]) +randomList 0 = return [] +randomList n = do + r <- randomRIO (1,10000) + rs <- randomList (n-1) + return (r:rs) + + +validation [] = True +validation (x:xs) = validation_cons x xs +validation_cons x [] = True +validation_cons x (y:ys) = + if x<=y then validation_cons y ys + else False + + +main = do + list <- randomList 20000 + let sorted = bsort list + print (validation sorted) -- cgit v1.2.3