Skip to content

Commit

Permalink
First working version of smith.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmacmanus committed Feb 7, 2019
1 parent e733d1d commit b9d05ac
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Binary file modified out/smith.exe
Binary file not shown.
Binary file modified src/LinearAlgebra/MatrixParser.o
Binary file not shown.
Binary file modified src/Main.hi
Binary file not shown.
11 changes: 8 additions & 3 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import System.Exit

-- TODO change getLine to getArgs and concatenate all args into one, the rest is the same

main = do l <- getLine
main = do ls <- getArgs
let l = concat ls
let m = parseMatrix l
putStrLn "Input:"
output m
let s = m >>= maybeSmith
putStrLn "Corresponding Smith normal-form:"
output s

output :: (Show a) => Maybe a -> IO ()
Expand All @@ -32,6 +35,8 @@ maybeSmith m = return $ smith m


invalidArgs = putStrLn msg >> exit where
msg = "Invalid arguments" -- TODO, write this up properly for usability
msg = "Error: Parse error on input. \n\n" ++
"Command should be of the form: \n" ++
">>> smith [[1,2,3],[4,5,6],[7,8,9]]"-- TODO, write this up properly for usability

exit = exitWith ExitSuccess
exit = exitWith ExitSuccess
Binary file modified src/Main.o
Binary file not shown.

0 comments on commit b9d05ac

Please sign in to comment.