Browse Source

Create a function to retrieve an integer

DricomDragon 5 years ago
parent
commit
b4abb88609
1 changed files with 9 additions and 0 deletions
  1. 9 0
      listfct.hs

+ 9 - 0
listfct.hs

@@ -1,9 +1,18 @@
+-- Reverse list order
 myexchanger xs zs = case xs of
 	[] -> zs
 	y:ys -> myexchanger ys (y:zs)
 
 myreverse xs = myexchanger xs []
 
+-- Delete the first item
 mydelete l y = case l of
 	[] -> []
 	x:xs -> if x == y then xs else x:(mydelete xs y)
+
+-- Find the maximum
+mymaximum l = mymaximumof l 0
+
+mymaximumof l x = case l of
+	[] -> x
+	y:ys -> if y > x then mymaximumof ys y else mymaximumof ys x