Smarter filename handling for AoC library main
authorNeil Smith <NeilNjae@users.noreply.github.com>
Wed, 8 Jan 2025 13:21:01 +0000 (13:21 +0000)
committerNeil Smith <NeilNjae@users.noreply.github.com>
Wed, 8 Jan 2025 13:21:01 +0000 (13:21 +0000)
src/AoC.hs

index 90b5c62b18f58c8e9fde85044090d99d0ac4e6d8..b3773a4ed4ebfe914caa445e0a9ee094721aa798 100644 (file)
@@ -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