Skip to content

Commit

Permalink
Simple lib file
Browse files Browse the repository at this point in the history
  • Loading branch information
Anup Kishore committed Feb 21, 2018
1 parent ae5b8a2 commit 678e069
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 1 addition & 4 deletions day1/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Main where
import Data.Char (digitToInt)
import Data.Text (strip, pack, unpack)
import Paths_aoc2017
import Lib (rotate)
import System.Environment (getArgs)
import System.Exit (exitSuccess)

Expand All @@ -14,10 +15,6 @@ file = getDataFileName "data/1-1"
getData :: IO [Int]
getData = map digitToInt . unpack . strip . pack <$> (readFile =<< file)

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

formPairs :: Int -> [Int] -> [(Int, Int)]
formPairs n l = zip l $ rotate n l

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

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

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

0 comments on commit 678e069

Please sign in to comment.