From 3a37525c65e593cfc8d33ef6a061f2866db37a3e Mon Sep 17 00:00:00 2001 From: able Date: Fri, 3 May 2024 13:43:17 -0500 Subject: [PATCH] More examples --- examples/comparison.lisp | 10 ++++++++++ examples/define.lisp | 2 +- examples/eval.lisp | 3 +++ examples/lambda.lisp | 9 +++++++-- examples/repl.lisp | 9 +++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 examples/comparison.lisp create mode 100644 examples/eval.lisp create mode 100644 examples/repl.lisp diff --git a/examples/comparison.lisp b/examples/comparison.lisp new file mode 100644 index 0000000..cbd60f2 --- /dev/null +++ b/examples/comparison.lisp @@ -0,0 +1,10 @@ +(eq 1 1) ; True +(eq 1 2) ; False + +(define a (λ () (+ 1 2 3))) +(define b (lambda () (+ 1 2 3))) +(eq a b) ; True + +(eq () nil) ; True + +(eq () (eval ())) ; True diff --git a/examples/define.lisp b/examples/define.lisp index 04d9686..c7b3df3 100644 --- a/examples/define.lisp +++ b/examples/define.lisp @@ -1,3 +1,3 @@ (define a 10) (define b 20) -(define c (+ a b)) \ No newline at end of file +(define c (lambda () (+ a b))) \ No newline at end of file diff --git a/examples/eval.lisp b/examples/eval.lisp new file mode 100644 index 0000000..6e4cca4 --- /dev/null +++ b/examples/eval.lisp @@ -0,0 +1,3 @@ +(eval + (quote + (+ 1 2))) \ No newline at end of file diff --git a/examples/lambda.lisp b/examples/lambda.lisp index 7cd4c43..30885e0 100644 --- a/examples/lambda.lisp +++ b/examples/lambda.lisp @@ -1,2 +1,7 @@ -(define a (λ () (+ 1 2 3))) -(a) \ No newline at end of file +(define a + (λ () + (+ 1 2 3))) + +(define b + (lambda () + (+ 1 2 3))) diff --git a/examples/repl.lisp b/examples/repl.lisp new file mode 100644 index 0000000..a0c3a2d --- /dev/null +++ b/examples/repl.lisp @@ -0,0 +1,9 @@ +(define repl + (lambda () ( + (print "λ -> ") + (print + (eval + (read))) + (print "\n") + (repl)))) +(repl)