In this article let’s discuss about Last element of list haskell. Let’s go through the following methods without any delay 🙂
list = [1, 2, 3, 4] last [a] -> a last [x] = x last (_:xs) = last xs last list -- 4
Method 2 :
list = [1,2,3,4,5] last list -- returns 5
Hope the above methods works for you. Happy Learning and get back to us Anytime.
Realted Posts : Small basic textwindow