module ToUpperFirst where import Data.Char (toUpper) toUpperFirst (x : xs) = toUpper x : xs toUpperFirst _ = ""
- module ToUpperFirst where
import Data.Char- import Data.Char (toUpper)
toUpperFirst "" = ""toUpperFirst (x : xs) = (toUpper x) : xs- toUpperFirst (x : xs) = toUpper x : xs
- toUpperFirst _ = ""
module AddNumbers where add_arr :: Num a => [a] -> a add_arr = sum
- module AddNumbers where
add_arr x = sum x- add_arr :: Num a => [a] -> a
- add_arr = sum
module AddNumbersSpec where import Test.Hspec import AddNumbers spec :: Spec spec = do describe "add_arr" $ do it "1..9" $ do (add_arr [1..9]) `shouldBe` (45) it "1..3,-4,5..9" $ do (add_arr [1,2,3,-4,5,6,7,8,9]) `shouldBe` (37) it "add_dec" $ do (add_arr [1.2, 2.3, 3.4]) `shouldBe` (6.9)
- module AddNumbersSpec where
- import Test.Hspec
- import AddNumbers
- spec :: Spec
- spec = do
- describe "add_arr" $ do
- it "1..9" $ do
- (add_arr [1..9]) `shouldBe` (45)
- it "1..3,-4,5..9" $ do
(add_arr [1,2,3,-4,5,6,7,8,9]) `shouldBe` (37)- (add_arr [1,2,3,-4,5,6,7,8,9]) `shouldBe` (37)
- it "add_dec" $ do
- (add_arr [1.2, 2.3, 3.4]) `shouldBe` (6.9)
module ToUpperFirst where import Data.Char (toUpper) mapcap :: String -> String mapcap = unwords . map (\(l:ls) -> toUpper l:ls) . words
- module ToUpperFirst where
import Data.Charimport Data.List- import Data.Char (toUpper)
- mapcap :: String -> String
mapcap = concat . intersperse " " . fmap (\(l:ls) -> (toUpper l):ls) . words- mapcap = unwords . map (\(l:ls) -> toUpper l:ls) . words