haskell return false if list empty
In Haskell, you can check if a list is empty using the null
function. The null
function returns True
if the list is empty, and False
otherwise. Here's an example:
isEmpty :: [a] -> Bool
isEmpty list = null list
In this example, isEmpty
is a function that takes a list as an argument and checks if it is empty using the null
function. It returns True
if the list is empty, and False
otherwise.