/lisp-machine

Implementation of Scheme programming language

Primary LanguageRust

LispDM

Description

LispDM is a Scheme interpreter written in Rust. It is based on the R7RS standard and provides a minimal set of built-in functions to write programs in Scheme. The interpreter is implemented as a library and can be used in other projects.

Docs

Features

  • Tail call optimization for recursion
  • Macros (like Clojure's defmacro)
  • Input-output (console and file)
  • Lazy evaluation
  • Pattern matching
  • REPL
  • Standard library

R7RS compatibility

Data types

  • boolean (#t, #f)
  • number (integer, real)
  • number (rational, complex)
  • string
  • symbol
  • list
  • pair (improper list)
  • char
  • procedure
  • port
  • vector
  • bytevector

Special forms

Implemented in Rust:

  • define
  • define-macro
  • set!
  • lambda
  • let (and named let)
  • letrec
  • if
  • cond
  • do
  • quote
  • quasiquote
  • unquote
  • unquote-splicing
  • include
  • load

Implemented in Scheme:

  • let*
  • letrec*
  • case
  • when
  • unless
  • and
  • or

Standard library

  • equivalence predicates:
    • eqv?
    • eq?
    • equal?
  • numbers:
    • number?
    • +
    • -
    • *
    • /
    • =
    • <
    • >
    • <=
    • >=
    • integer?
    • zero?
    • positive?
    • negative?
    • odd?
    • even?
    • abs
    • min
    • max
    • modulo
    • quotient
    • remainder
    • floor
    • ceiling
    • truncate
    • round
    • square
    • sqrt
    • expt
    • number->string
    • string->number
  • booleans:
    • boolean?
    • not
    • and
    • or
  • pairs and lists:
    • pair?
    • cons
    • car
    • cdr
    • caar
    • cadr
    • cdar
    • cddr
    • caaar, caadr, ..., cddar, cdddr
    • null?
    • list?
    • make-list
    • list
    • length
    • append
    • reverse
    • list-tail
    • list-ref
    • memq
    • memv
    • member
    • assq
    • assv
    • assoc
    • list-copy
  • symbols:
    • symbol?
    • symbol->string
    • string->symbol
  • characters:
    • char?
    • char=?
    • char<?
    • char>?
    • char<=?
    • char>=?
    • char-alphabetic?
    • char-numeric?
    • char-whitespace?
    • char-upper-case?
    • char-lower-case?
    • digit-value
    • char->integer
    • integer->char
    • char-upcase
    • char-downcase
    • char-foldcase
  • strings:
    • string?
    • string=?
    • string<?
    • string>?
    • string<=?
    • string>=?
    • make-string
    • string
    • string-length
    • string-ref
    • string-set!
    • string-upcase
    • string-downcase
    • string-foldcase
    • substring
    • string-append
    • string->list
    • list->string
    • string-copy
    • string-copy!
    • string-fill!
  • controls:
    • procedure?
    • apply
    • eval
    • map
    • string-map
    • for-each
    • string-for-each
  • ports:
    • port?
    • call-with-input-file
    • call-with-output-file
    • with-input-from-file
    • with-output-to-file
    • input-port?
    • output-port?
    • current-input-port
    • current-output-port
    • open-input-file
    • open-output-file
    • close-input-port
    • close-output-port
    • eof-object?
    • eof-object
  • input/output:
    • read
    • read-char
    • read-string
    • write
    • write-char
    • write-string
    • display
    • newline
  • system interface:
    • load
    • file-exists?
    • delete-file
    • command-line
    • exit
    • get-environment-variable
    • get-environment-variables
    • current-second

Extensions

  • pattern matching with match
  • lazy evaluation:
    • delay
    • force
    • lazy-car
    • lazy-cdr
    • lazy-cons
    • lazy-map
    • lazy-filter
    • lazy-ref
    • head