RosettaCodeData/Task/Ackermann-function/Agda/ackermann-function-1.agda

26 lines
574 B
Agda
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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