Skip to content

Latest commit

 

History

History
108 lines (105 loc) · 1.59 KB

SPEC.md

File metadata and controls

108 lines (105 loc) · 1.59 KB

Lithia

lisp implemented in rust

Name

Name comes from another name for Lithium Oxide

Functions

  • quote Returns whatever its given, used for when you don't want to evaluate something
    (quote pi)
    => pi
    
  • exit Exit lisp interpreter, number may be provided for exit code
    (exit 1)
  • =, set Sets a variable
    (set foo "bar")
  • def Define a global
    (def foo "bar")
  • defunc Define a global function
    (defunc name (arg1 arg2)
    	(body)
    	(body)
    	return_value)
  • eval Evaluates the given object and what it returns
    (eval (quote pi))
    => 3.1415927
    
  • print Display an object
    (print "hello world")
  • read Reads a line into objects
    (read "> ")
  • include Reads a file and evaluates it, returning the last object
    (include "hello.lisp")
  • while While first argument isn't nil, evaluates the rest
    (= x 0)
    (while (!= x 3)
        (print x)
        (= x (+ x 1)))
    0
    1
    2
    
  • func Creates a function
    • Use:
     (func (arg1 arg2)
     	(body)
     	(body)
     	return_value)
  • car Gets the first element in a dot-pair
    (car '(foo . bar))
    => foo
    
  • cdr Gets the second element in a dot-pair
    (cdr '(foo . bar))
    => bar
    

Maths functions

  • +, add
  • -, sub
  • *, mul
  • /, div
  • %, mod
  • ==, eq
  • !=, ne