Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- using conditionals
- safetail :: [a] -> [a]
- safetail a = if null a then [] else tail a
- -- using guarded equations
- safetail' :: [a] -> [a]
- safetail' xs | null xs = []
- | otherwise = tail xs
- -- using pattern matching
- safetail'' :: [a] -> [a]
- safetail'' [] = []
- safetail'' (_:xs) = xs
- -- my or operator
- (||!) :: Bool -> Bool -> Bool
- True ||! True = True
- True ||! False = True
- False ||! True = True
- False ||! False = False
- -- another or operator
- (||#) :: Bool -> Bool -> Bool
- False ||# False = False
- _ ||# _ = True
- -- and another or operator
- (||@) :: Bool -> Bool -> Bool
- False ||@ b = b
- True ||@ _ = True
Add Comment
Please, Sign In to add comment