listfct.hs 494 B

1234567891011121314151617181920212223
  1. -- Reverse list order
  2. myexchanger xs zs = case xs of
  3. [] -> zs
  4. y:ys -> myexchanger ys (y:zs)
  5. myreverse xs = myexchanger xs []
  6. -- Delete the first item
  7. mydelete l y = case l of
  8. [] -> []
  9. x:xs -> if x == y then xs else x:(mydelete xs y)
  10. -- Find the maximum
  11. mymaximum l = mymaximumof l 0
  12. mymaximumof l x = case l of
  13. [] -> x
  14. y:ys -> if y > x then mymaximumof ys y else mymaximumof ys x
  15. -- Sort the list
  16. trimax l = if l == []
  17. then []
  18. else let y = mymaximum l in y:(trimax (mydelete l y))