summaryrefslogtreecommitdiff
path: root/Haskell-book/03/src/Main.purs
blob: d73dc74abc4dbb28f9e92fd62b4ee5836693497f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module Main where

import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Data.String (singleton, drop, take)
import Data.String.Unsafe (charAt)

-- Given
-- "Curry is awesome"
-- Return
-- "Curry is awesome!"
a :: String -> String
a x = x <> "!"

-- Given
-- "Curry is awesome!"
-- Return
-- "y"
b :: String -> String
b x = singleton $ charAt 4 x

-- Given
-- "Curry is awesome!"
-- Return
-- "awesome!"
c :: String -> String
c = drop 9

-- If you apply your function to this value:
-- "Curry is awesome"
-- Your function should return
-- 'r'
thirdLetter :: String -> Char
thirdLetter = charAt 2

letterIndex :: Int -> Char
letterIndex x = charAt x "Curry is awesome!"

rvrs :: String -> String
rvrs inp = (drop 9 inp) <> (drop 5 $ take 9 inp) <> (take 5 inp)

main :: forall e. Eff (console :: CONSOLE | e) Unit
main = do
  log $ rvrs "Curry is awesome"