summaryrefslogtreecommitdiff
path: root/tests/fact.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-08-02 17:04:14 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-08-02 17:04:14 -0400
commitb219af5f765fbc789a7f54f50862e6730ae141fd (patch)
tree826cbdb7565674b7e6c1e8161bce1f4d5655a942 /tests/fact.ur
parent1a96e18000db336129e0a99e3c86e7a57f152402 (diff)
Compile self-tail-calls as gotos
Diffstat (limited to 'tests/fact.ur')
-rw-r--r--tests/fact.ur5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/fact.ur b/tests/fact.ur
new file mode 100644
index 00000000..c7989a3b
--- /dev/null
+++ b/tests/fact.ur
@@ -0,0 +1,5 @@
+fun fact n = if n <= 1 then 1 else n * fact (n - 1)
+
+fun factTr n acc = if n <= 1 then acc else factTr (n - 1) (n * acc)
+
+fun main () : transaction page = return <xml>{[fact 10]}, {[factTr 10 1]}</xml>