Browse Source

Problem 01

completed
Craige McWhirter 7 months ago
parent
commit
d93cdd53f1
Signed by: craige GPG Key ID: 7DBA9F5689EFB6AA
  1. 11
      myLast.hs

11
myLast.hs

@ -0,0 +1,11 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}
-- Find the last element of a list
-- "xs" grabs the tail
myLast :: [a] -> a
myLast [] = error "No end for empty lists!"
myLast [x] = x
myLast (_:xs) = myLast xs
Loading…
Cancel
Save