Added wryls lisp example

This commit is contained in:
Devine Lu Linvega 2024-05-06 19:29:14 -07:00
parent 0f3c1b4fb8
commit 1f7e382c92
1 changed files with 22 additions and 0 deletions

22
examples/lisp.modal Normal file
View File

@ -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))