Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Ackermann-function/Agda/ackermann-function-1.agda
Normal file
25
Task/Ackermann-function/Agda/ackermann-function-1.agda
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
module Ackermann where
|
||||
|
||||
open import Data.Nat using (ℕ ; zero ; suc ; _+_)
|
||||
|
||||
ack : ℕ → ℕ → ℕ
|
||||
ack zero n = n + 1
|
||||
ack (suc m) zero = ack m 1
|
||||
ack (suc m) (suc n) = ack m (ack (suc m) n)
|
||||
|
||||
|
||||
open import Agda.Builtin.IO using (IO)
|
||||
open import Agda.Builtin.Unit using (⊤)
|
||||
open import Agda.Builtin.String using (String)
|
||||
open import Data.Nat.Show using (show)
|
||||
|
||||
postulate putStrLn : String → IO ⊤
|
||||
{-# FOREIGN GHC import qualified Data.Text as T #-}
|
||||
{-# COMPILE GHC putStrLn = putStrLn . T.unpack #-}
|
||||
|
||||
main : IO ⊤
|
||||
main = putStrLn (show (ack 3 9))
|
||||
|
||||
|
||||
-- Output:
|
||||
-- 4093
|
||||
2
Task/Ackermann-function/Agda/ackermann-function-2.agda
Normal file
2
Task/Ackermann-function/Agda/ackermann-function-2.agda
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
agda --compile Ackermann.agda
|
||||
./Ackermann
|
||||
Loading…
Add table
Add a link
Reference in a new issue