Answers for "how to test for last element in a list haskell"

3

last element of list haskell

list = [1, 2, 3, 4]

last [a] -> a
last [x] 	= x
last (_:xs) = last xs

last list -- 4
Posted by: Guest on October-18-2020

Code answers related to "how to test for last element in a list haskell"

Browse Popular Code Answers by Language