summaryrefslogtreecommitdiff
path: root/gnomesort.hs
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2015-10-17 14:20:48 +1100
committerJed Barber <jjbarber@y7mail.com>2015-10-17 14:20:48 +1100
commit63c3043200de6b28a8c192f1b5625940435ea55e (patch)
treeab761edbbc71b2b2f28e0ef7e10b8adc58d44320 /gnomesort.hs
parent5933f248c18914fbbce03102b340361a575eae3c (diff)
Organised source code a bit, added makefile with clean target
Diffstat (limited to 'gnomesort.hs')
-rw-r--r--gnomesort.hs19
1 files changed, 0 insertions, 19 deletions
diff --git a/gnomesort.hs b/gnomesort.hs
deleted file mode 100644
index 2a9b9ce..0000000
--- a/gnomesort.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-gnomeSort :: Ord a => [a] -> [a]
-gnomeSort list = doGnomeSort list 1
-
-
-
-doGnomeSort :: Ord a => [a] -> Int -> [a]
-doGnomeSort list pos | pos >= length list = list
-doGnomeSort list pos =
- if (list !! pos) >= (list !! (pos - 1))
- then doGnomeSort list (pos + 1)
- else let list' = (take (pos - 1) list) ++ [list !! pos] ++
- [list !! (pos - 1)] ++ (drop (pos + 1) list)
- pos' = if pos > 1 then pos - 1 else pos
- in doGnomeSort list' pos'
-
-