Skip to content

Commit

Permalink
Move wordToInt to Lib file
Browse files Browse the repository at this point in the history
  • Loading branch information
Anup Kishore committed Feb 22, 2018
1 parent 863bb2d commit 1cd4f4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions day2/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import Control.Arrow ((&&&))
import Data.Char (isSpace)
import Data.Text (split, pack, unpack)
import Paths_aoc2017
import Lib (wordToInt)
import System.Environment (getArgs)
import System.Exit (exitSuccess)

file :: IO FilePath
file = getDataFileName "data/2-1"

wordToInt :: String -> Int
wordToInt = read

getData :: IO [[Int]]
getData = map (map (wordToInt . unpack) . split isSpace . pack) . lines <$> (readFile =<< file)

Expand Down
10 changes: 5 additions & 5 deletions src/Lib.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Lib
( someFunc
, rotate
( rotate
, wordToInt
) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"

rotate :: Int -> [a] -> [a]
rotate _ [] = []
rotate n xs = drop n xs ++ take n xs

wordToInt :: String -> Int
wordToInt = read

0 comments on commit 1cd4f4f

Please sign in to comment.