From 17c5486551fa3de783f7c5371eb57ddc19bec552 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 12 Jun 2019 19:31:49 -0700 Subject: [PATCH] Add good old factorial. --- programs/factorial.lily | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 programs/factorial.lily diff --git a/programs/factorial.lily b/programs/factorial.lily new file mode 100644 index 0000000..9947a6a --- /dev/null +++ b/programs/factorial.lily @@ -0,0 +1,12 @@ +defn if c t e = { + case c of { + True -> { t } + False -> { e } + } +} + +defn fact n = { + if (eq n 0) 1 (n * fact (n - 1)) +} + +defn main = { fact 6 }