├── examples
├── fact100.l
├── fib15.l
├── qsort.l
├── interp_in_thread.cs
├── eval-fib15.l
└── eval-eval-fib15.l
├── lisp.csproj
├── LICENSE
├── README.md
├── IMPLEMENTATION-NOTES.md
├── arith.cs
└── lisp.cs
/examples/fact100.l:
--------------------------------------------------------------------------------
1 | (defun factorial (n)
2 | (if (= n 0)
3 | 1
4 | (* n (factorial (- n 1)))))
5 |
6 | (print (factorial 100))
7 |
--------------------------------------------------------------------------------
/examples/fib15.l:
--------------------------------------------------------------------------------
1 | (defun fib (n)
2 | (if (< n 2)
3 | 1
4 | (+ (fib (- n 1))
5 | (fib (- n 2)))))
6 | (print (fib 15))
7 |
--------------------------------------------------------------------------------
/lisp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | False
7 | False
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/qsort.l:
--------------------------------------------------------------------------------
1 | ;; quick sort for a sequence
2 | (defun qsort (seq) (_qsort seq nil))
3 |
4 | (defun _qsort (left-seq right-sorted)
5 | (if (null left-seq)
6 | right-sorted
7 | (let ((pivot (car left-seq))
8 | (tail (cdr left-seq)))
9 | (let ((pair (_split pivot tail)))
10 | (let ((left (car pair))
11 | (right (cons pivot
12 | (_qsort (cadr pair) right-sorted))))
13 | (_qsort left right))))))
14 |
15 | (defun _split (pivot seq) ; => (left-seq right-seq)
16 | (if (null seq)
17 | (list nil nil)
18 | (let ((x (car seq))
19 | (tail-pair (_split pivot (cdr seq))))
20 | (if (< x pivot)
21 | (list (cons x (car tail-pair))
22 | (cadr tail-pair))
23 | (list (car tail-pair)
24 | (cons x (cadr tail-pair)))))))
25 |
26 | (print (qsort '(3 1 4 1 5 9 2 6 5 3 5 8 9 7 9)))
27 | ;; => (1 1 2 3 3 4 5 5 5 6 7 8 9 9 9)
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 OKI Software Co., Ltd.
2 | Copyright (c) 2018 SUZUKI Hisao
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a
5 | copy of this software and associated documentation files (the "Software"),
6 | to deal in the Software without restriction, including without limitation
7 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | and/or sell copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/examples/interp_in_thread.cs:
--------------------------------------------------------------------------------
1 | // An example of running Lisp in another thread
2 | using System;
3 | using System.Collections.Concurrent;
4 | using System.IO;
5 | using System.Text;
6 | using System.Threading;
7 |
8 | // csc -o -t:library -r:System.Numerics.dll ../lisp.cs ../arith.cs
9 | // csc -r:lisp.dll interp_in_thread.cs
10 | // mono interp_in_thread.exe
11 |
12 | // Expected output:
13 | // => (1 . 2)
14 | // Reiwa
15 | // => Reiwa
16 |
17 | public static class ThreadTest {
18 |
19 | // A simple substitute for Console.Out
20 | class SendOut: TextWriter {
21 | public BlockingCollection