From e1bb5760e0ac587cd6a80d7063cc33a6c747399b Mon Sep 17 00:00:00 2001 From: Martin Fredin Date: Mon, 15 May 2023 00:27:48 +0200 Subject: [PATCH] Fix quicksort example --- sample-programs/{Quicksort.crf => working/quicksort.crf} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename sample-programs/{Quicksort.crf => working/quicksort.crf} (79%) diff --git a/sample-programs/Quicksort.crf b/sample-programs/working/quicksort.crf similarity index 79% rename from sample-programs/Quicksort.crf rename to sample-programs/working/quicksort.crf index 07dd352..d37651e 100644 --- a/sample-programs/Quicksort.crf +++ b/sample-programs/working/quicksort.crf @@ -16,13 +16,15 @@ toChar x = case x of 8 => '8' 9 => '9' +filter : (a -> Bool) -> List a -> List a filter p xs = case xs of Nil => Nil Cons x xs => case p x of True => Cons x (filter p xs) False => filter p xs -(++) as bs = case as of +.++ : List a -> List a -> List a +.++ as bs = case as of Nil => bs Cons x xs => Cons x (xs ++ bs) @@ -38,4 +40,5 @@ descList from to = case to < from of False => Cons to (descList from (to - 1)) True => Nil --- main = let list = (5 :: (2 :: (8 :: (9 :: (6 :: (0 :: (1 :: Nil))))))) in printStr (toStr (quicksort list)) +main = let list = Cons 5 (Cons 2 (Cons 8 (Cons 9 (Cons 6 (Cons 0 (Cons 1 Nil)))))) in + printStr (toStr (quicksort list))