Coder Social home page Coder Social logo

lisp-in-dart's Introduction

Lisp in Dart

This is a small Lisp interpreter I wrote 3 years ago (2015) in Dart. It had been presented under the MIT License at http://www.oki-osk.jp/esc/dart/lisp.html until last spring (2017). Now I have slightly modified it to match Dart 2.0.

See IMPLEMENTATION-NOTES.md for the details of implementation.

How to use

It runs in Dart 1.24 and later.

$ dart lisp.dart
> "hello, world"
"hello, world"
> (+ 5 6)
11
> (exit 0)
$

You can give it a file name of your Lisp script.

$ dart lisp.dart examples/fib15.l
987
$

If you put a "-" after the file name, it will begin an interactive session after running the file.

$ dart lisp.dart examples/fib15.l -
987
> (fib 0)
1
> (fib 1)
1
> (fib 2)
2
> (exit 0)
$ 

Examples

There are four files ending with .l under the examples folder. These run also in Emacs Lisp and Common Lisp. You will find the Lisp in Dart comparably fast to Emacs Lisp which is written in C.

$ dart lisp.dart examples/qsort.l
(1 1 2 3 3 4 5 5 5 6 7 8 9 9 9)
$ 
$ emacs -batch -l examples/qsort.l

(1 1 2 3 3 4 5 5 5 6 7 8 9 9 9)
$ 
$ clisp examples/qsort.l

(1 1 2 3 3 4 5 5 5 6 7 8 9 9 9)
$ 
  • qsort.l performs a quick sort.

  • fib15.l calculates Fibonacci for 15.

  • eval-fib15.l calculates Fibonacci for 15 on a meta-circular Lisp evaluator.

  • eval-eval-fib15.l calculates Fibonacci for 15 on a meta-circular Lisp evaluator on a meta-circular Lisp evaluator.

There is one more example:

  • interp_in_isolate.dart runs a Lisp interpreter in another isolate of Dart. You can embed an interpreter within your Flutter app in the same way.
$ dart examples/interp_in_isolate.dart
=> 11
=> 1
=> (1)

The examples of eval-fib15.l and eval-eval-fib15.l are inspired by https://github.com/zick/ZickStandardLisp.

License

This is under the MIT License. See lisp.dart.

lisp-in-dart's People

Contributors

nukata avatar

Watchers

none-p avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.