Answers for "haskell get last element of list"

2

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
2

haskell get last element of list

list = [1,2,3,4,5]
last list -- returns 5
Posted by: Guest on June-03-2020

Code answers related to "haskell get last element of list"

Browse Popular Code Answers by Language