From 1f7e382c927d7b9fec915dea91567bf187ed1a0c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 6 May 2024 19:29:14 -0700 Subject: [PATCH] Added wryls lisp example --- examples/lisp.modal | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/lisp.modal diff --git a/examples/lisp.modal b/examples/lisp.modal new file mode 100644 index 0000000..3264847 --- /dev/null +++ b/examples/lisp.modal @@ -0,0 +1,22 @@ +<> ((defun ?n ?p ?b)) (defun ?n ?p ?b) +<> (defun ?n ?p ?b) (<> (?n ?p) ?b) +<> (q ?x) (q ?x) +<> ((unwrap ?x)) (unwrap ?x) +<> (unwrap ((?x))) (unwrap (?x)) +<> (unwrap ?x) ?x +<> (if ?c ?t ?f) (if/q ?c q ?t q ?f) +<> (if/q (true) q ?t q ?f) (unwrap ?t) +<> (if/q (false) q ?t q ?f) (unwrap ?f) +<> (== (?x) (?x)) (true) +<> (== (?x) (?y)) (false) +<> (math ?: ?0 ?1) ?: +<> (+ (?x) (?y)) (math + ?x ?y) +<> (- (?x) (?y)) (math - ?x ?y) +<> (* (?x) (?y)) (math * ?x ?y) + +(defun factorial (?n) + (if (== (?n) (1)) + (?n) + (* (?n) (factorial (- (?n) (1)))))) + +(factorial (5)) \ No newline at end of file