Jelajahi Sumber

Create a function to retrieve an integer

DricomDragon 5 tahun lalu
induk
melakukan
b4abb88609
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  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