changeset 252:e937bf565bf8

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 12 Dec 2020 21:35:49 +0900
parents d782dd481a26
children b46a3a3f45af
files sym5n.agda
diffstat 1 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sym5n.agda	Sat Dec 12 20:28:29 2020 +0900
+++ b/sym5n.agda	Sat Dec 12 21:35:49 2020 +0900
@@ -59,7 +59,39 @@
    FListtoStr [] = ""
    FListtoStr (cons a x x₁) = primStringAppend (FLtoStr a) (primStringAppend "\n" (FListtoStr x))
 
-open import IO -- using (IO)
+-- open import IO -- using (IO)
+open import Data.Maybe hiding (_>>=_)
+open import Data.List  -- using (IO)
+open import Foreign.Haskell using (Unit)
+open import IO.Primitive
+open import Codata.Musical.Costring
+
+postulate
+   getArgs : IO (List String)
+{-# FOREIGN GHC import qualified System.Environment    #-}
+{-# COMPILE GHC getArgs = System.Environment.getArgs #-}
 
-main = run ( putStrLn $ sym5solvable 4)
+charToDigit : String → Maybe ℕ
+charToDigit "0" = just ( 0)
+charToDigit "1" = just ( 1)
+charToDigit "2" = just ( 2)
+charToDigit "3" = just ( 3)
+charToDigit "4" = just ( 4)
+charToDigit "5" = just ( 5)
+charToDigit "6" = just ( 6)
+charToDigit "7" = just ( 7)
+charToDigit "8" = just ( 8)
+charToDigit "9" = just ( 9)
+charToDigit _   = nothing
 
+getNumArg1 : (List String) → ℕ
+getNumArg1 [] = 0
+getNumArg1 (x ∷ y) with charToDigit x
+... | just n = n
+... | nothing  = 0
+
+main : IO ⊤
+main = do
+   x <- getArgs
+   putStrLn $ toCostring $ sym5solvable $ getNumArg1 x
+