• Stars
    star
    52
  • Rank 560,474 (Top 12 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Minimal Lisp interpreter using 75LOC and only standard libraries.

lisp

Gem Version Gem Build Status

Minimal Lisp interpreter using 75LOC and only standard libraries excluding the REPL. Inspired by Lis.py.

$ lisp-repl
ctrl-c to exit
> (begin                                                                        
(>   (define incf                                                               
((>     (lambda (x)                                                             
(((>       (set! x (+ x 1))))                                                   
(>   (define one 1)                                                             
(>   (incf one))                                                                
2
>                                      

Install

gem install lisp

Usage

require "lisp"

Lisp.eval(<<-eos)
  (begin
    (define fact
      (lambda (n)
        (if (<= n 1)
          1
          (* n (fact (- n 1))))))
    (fact 10))
eos # => 3628800

Commandline

lisp-repl

Documentation

Yardoc

Rubygem

Features

  • constant literal number - A number evaluates to itself. Example: 12 or -3.45e+6

  • procedure call - (proc exp...) If proc is anything other than one of the symbols if, set!, define, lambda, begin, or quote then it is treated as a procedure. It is evaluated using the same rules defined here. All the expressions are evaluated as well, and then the procedure is called with the list of expressions as arguments. Example: (square 12) β‡’ 144

  • variable reference - var A symbol is interpreted as a variable name; its value is the variable's value. Example: x

  • definition - (define var exp) Define a new variable and give it the value of evaluating the expression exp. Examples: (define r 3) or (define square (lambda (x) (* x x))).

  • procedure - (lambda (var...) exp) Create a procedure with parameter(s) named var... and the expression as the body. Example: (lambda (r) (* 3.141592653 (* r r)))

  • conditional - (if test conseq alt) Evaluate test; if true, evaluate and return conseq; otherwise evaluate and return alt. Example: (if (< 10 20) (+ 1 1) (+ 3 3)) β‡’ 2

  • quotation - (quote exp) Return the exp literally; do not evaluate it. Example: (quote (a b c)) β‡’ (a b c)

  • assignment - (set! var exp) Evaluate exp and assign that value to var, which must have been previously defined (with a define or as a parameter to an enclosing procedure). Example: (set! x2 (* x x))

  • sequencing - (begin exp...) Evaluate each of the expressions in left-to-right order, and return the final value. Example: (begin (set! x 1) (set! x (+ x 1)) (* x 2)) β‡’ 4

More Repositories

1

forward-proxy

Minimal HTTP(S) forward proxy using 150LOC and only standard libraries.
Ruby
152
star
2

scorched_earth

Scorched Earth clone in JRuby with no dependencies.
Ruby
129
star
3

gohack

Experimental Go language CSGO exploit.
Go
68
star
4

gomem

A Go library for manipulating Windows processes.
Go
50
star
5

nebula

WebGL top down space shooter.
CoffeeScript
50
star
6

react-instagram-authless-feed

React component to provide a token-less Instagram feed.
JavaScript
49
star
7

cfn-cheapest-nat

Cheapest AWS VPC NAT.
36
star
8

angularjs-rss-reader

RSS reader in Javascript / AngularJS.
JavaScript
29
star
9

goforward

Go forward proxy with bandwidth limiting.
Go
27
star
10

poto

multi cloud storage to image gallery + image proxy + file api - 350 LOC.
Ruby
19
star
11

alpaca-desktop

Experimental OSX menu bar widget for Alpaca.
Ruby
19
star
12

call-graph

Capture execution and create dependency graphs.
Ruby
17
star
13

interceptor

Ruby method interceptors.
Ruby
10
star
14

trie

Ruby trie data structure.
Ruby
5
star
15

chingu-template

Simple template for a Chingu application.
Ruby
5
star
16

redux-paint

Simple "time-traveling" paint application.
TypeScript
5
star
17

simple-sinatra-sequel-blog

A simple blog with Sinatra and Sequel.
Ruby
4
star
18

tf-idf

Ruby Gem to calculate tf*idf
CSS
3
star
19

k8s-gitops

k8s gitops home lab.
Shell
3
star
20

gobackground

Golang, winuser.dll, advapi32.dll, to create a random unsplashed background binary.
Go
3
star
21

godll

Example of Go & Windows DLL build and usage.
Go
3
star
22

gobat2exe

Convert Windows batch files into executable files.
Go
3
star
23

vagrant-metasploit

2
star
24

pi-playbook

Configure Raspberry Pi with Ansible
2
star
25

chef-pptpd

Chef PPTPDrecipe.
Ruby
2
star
26

thread-pool

Ruby thread pool.
Ruby
2
star
27

gobot

Go learning exercise.
Go
1
star
28

cfn-static-website-with-lambda-at-edge

Static website hosted from an S3 Bucket delivered via Cloudfront with Lambda@Edge.
Shell
1
star
29

jamesmoriarty.github.io

Github Pages
HTML
1
star
30

cfn-vpc

A simple VPC including public and private subnets over multiple AZs.
1
star
31

react-email-signature

JavaScript
1
star
32

scala-robot

Scala
1
star
33

mini-aasm

A State Machine library intended to be compatible with lightweight implementations of the Ruby language using 100LOC and only standard libraries.
Ruby
1
star
34

scheduler-dataflow-demo

Java
1
star
35

chef-minidlna

Chef MiniDLNA recipe.
Ruby
1
star
36

experiment-nginx-proxy-pass-forward-proxy

1
star
37

rack-playbook

Deploy compatible rack apps with ansible.
Ruby
1
star
38

docker-pmd

Dockerfile for PMD an extensible cross-language static code analyzer.
Dockerfile
1
star
39

kotlin-robot

Kotlin
1
star
40

victoria-exposure-site-bot

Ruby
1
star
41

chef-qt-webkit-devel

Ruby
1
star
42

experiment-dns-resolve

1
star
43

k3s-host-network-experiment

Why did my minidlna setup stop working?
Shell
1
star
44

experiment-fail-fast-mirroring

Shell
1
star