Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Haskell
foo :: [a] -> Maybe a
foo [] = Nothing
foo xs = Just $ last xs

x = foo items

items is a list of homogeneous elements
x = last items

Crashes if items is empty
X := Items'Last

X must be declared earlier.

New implementation...