瀏覽代碼

Create a function to retrieve an integer

DricomDragon 5 年之前
父節點
當前提交
b4abb88609
共有 1 個文件被更改,包括 9 次插入0 次删除
  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