From: Neil Smith Date: Thu, 8 Dec 2016 09:51:24 +0000 (+0000) Subject: Used init instead of reverse $ tail $ reverse X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=ec30873176b8aacf504bc3b5919c0a161a74b1f0;p=advent-of-code-16.git Used init instead of reverse $ tail $ reverse --- diff --git a/advent04.hs b/advent04.hs index 135ad37..b8c095e 100644 --- a/advent04.hs +++ b/advent04.hs @@ -1,6 +1,6 @@ module Main(main) where -import Data.List (last, intersperse, sortBy, intercalate, isInfixOf) +import Data.List (last, intersperse, sortBy, intercalate, isInfixOf, init) import Data.List.Split (splitOn) import Data.Char (isLetter, ord, chr) import qualified Data.Map.Lazy as Map @@ -38,7 +38,7 @@ part2 rooms = do parseLine :: String -> Room parseLine line = Room {name=name, sector=sector, checksum=checksum} where components = splitOn "-" line - name = intercalate "-" $ reverse $ tail $ reverse components + name = intercalate "-" $ init components sector = read $ head $ splitOn "[" $ last components checksum = filter (isLetter) $ last components