Added 'Haskell/5.hs'

This commit is contained in:
anon 2024-07-22 19:39:19 +02:00
parent 658974a97f
commit 687cc50a84

31
Haskell/5.hs Normal file
View File

@ -0,0 +1,31 @@
import Data.Char (toUpper)
headInt :: [Int] -> Int
headInt (x:_) = x
tailInt :: [Int] -> [Int]
tailInt (x:xs) = xs
nullInt :: [Int] -> Bool
nullInt [] = True
nullInt _ = False
isSingleton :: [Int] -> Bool
isSingleton [x] = True
isSingleton _ = False
toUpperFirst :: [Char] -> [Char]
toUpperFirst [] = []
toUpperFirst (x:xs) = toUpper x : xs
isLetter :: Char -> Bool
isLetter x = elem x ['A'..'z']
compTest :: Char -> [Char]
compTest x = [x..'z']
mountain :: Int -> [Int]
mountain x = [1..x] ++ [x - 1, x - 2 .. 1]
divisors :: Int -> [Int]
divisors n = [d | d <- [1..n], mod n d == 0]