From d2f7ffa657b156eeae906169e911eaaefafac893 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Wed, 8 Jan 2025 13:21:01 +0000 Subject: [PATCH] Smarter filename handling for AoC library --- src/AoC.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/AoC.hs b/src/AoC.hs index 90b5c62..b3773a4 100644 --- a/src/AoC.hs +++ b/src/AoC.hs @@ -1,16 +1,18 @@ module AoC ( getDataFileName ) where import System.Environment +import Data.Char getDataFileName :: IO String getDataFileName = do args <- getArgs progName <- getProgName + let progName' = reverse $ dropWhile isLetter $ reverse progName let baseDataName = if null args - then progName + then progName' else head args let baseDataName' = if length baseDataName < 5 - then progName ++ baseDataName + then progName' ++ baseDataName else baseDataName let dataFileName = "../data/" ++ baseDataName' ++ ".txt" return dataFileName -- 2.34.1