diff options
-rw-r--r-- | Main.hs | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -5,8 +5,10 @@ import Text.Printf errorMessage :: String -> String -errorMessage "" = "nd v1\nUsage: nd [-int, -prime, -factor, -hcf]" -errorMessage reason = "nd v1\nFAILURE: " ++ reason ++ "\nUsage: nd [-int, -prime, -factor, -hcf]" +errorMessage "" = "nd v1\nUsage: nd [-help, -int, -prime, -factor, -hcf]\n" +errorMessage reason = "nd v1\nFAILURE: " + ++ reason + ++ "\nUsage: nd [-int, -prime, -factor, -hcf]\n" flagHandlerF :: [String] -> Int -> String -> ([String] -> String) -> String @@ -55,8 +57,9 @@ flagHandler "-hcf" args = hcf = head $ reverse $ intersect (factors n) (factors m) in "hcf(" ++ show n ++ ", " ++ show m ++ "): hcf=" ++ show hcf) +flagHandler _ _ = + errorMessage "Flag not recognised" -flagHandler _ _ = errorMessage "Didn't recognise flag" main = do args <- getArgs |