[–] suzuki 11y ago ↗ This is a Lisp interpreter with macros, backquotation and tail-call optimization. It is written in 1,200 lines of a script in Dart 1.9. $ curl -R -O http://www.oki-osk.jp/esc/dart/lisp/lisp-27-04-20.tar.bz2 $ tar xf lisp-27-04-20.tar.bz2 $ cd lisp-27-04-20 $ wc lisp.dart 1200 4696 36500 lisp.dart $ dart lisp.dart > (defmacro aif (test then &rest else) `(let ((it ,test)) (if it ,then ,@else))) aif > (defun find (x list) (aif (member x list) (car it))) find > (find 10 '(1 2 3)) nil > (find 2 '(1 2 3)) 2 > find #<closure:2:nil:((#<lambda:1:((cond (#0:0:it (car #0:0:it))))> (member #0:0:x #0:1:list)))>
1 comment
[ 414 ms ] story [ 1276 ms ] thread