From 678e0696ba3fe2c974ab1e1998d0a54ceab2fb3c Mon Sep 17 00:00:00 2001 From: Anup Kishore Date: Wed, 21 Feb 2018 11:21:26 +0530 Subject: [PATCH] Simple lib file --- day1/Main.hs | 5 +---- src/Lib.hs | 9 +++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/day1/Main.hs b/day1/Main.hs index 2ba997b..9271eaf 100644 --- a/day1/Main.hs +++ b/day1/Main.hs @@ -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) @@ -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 diff --git a/src/Lib.hs b/src/Lib.hs index d36ff27..7f09084 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -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