Added 'Haskell/5.hs'
This commit is contained in:
parent
658974a97f
commit
687cc50a84
31
Haskell/5.hs
Normal file
31
Haskell/5.hs
Normal 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]
|
Loading…
x
Reference in New Issue
Block a user