miniMAL

A Delightfully Diminutive Lisp

miniMAL:  min ( 824 bytes), orig (4053 bytes, 119 lines)
Core Lib: min (1086 bytes), orig (4161 bytes, 120 lines)

miniMAL at a glance

Lisp-0 / JSON Source

Scalars 123, null, true, false, "symbol", "+"
Strings ["`", "quoted symbol is a string"]
List [7, 8, 9]
Objects {"a": 123, "b": 789}

Functions

Calling ["+", 2, 3]
Anonymous ["fn", ["a"], ["+", 2, "a"]]
Named ["def", "inc2",
  ["fn", ["a"], ["+", 2, "a"]]]
Higher Order ["map", "inc2",
  ["list", 2,3,4]]
Variadic ["def", "drop1",
  ["fn", ["a", "&", "b"], "b"]]

Core Library

Math "+", "-", "*", "/"
Conditional Macros "and", "or"
Comparison/Boolean "=", "<", ">", "<=", ">=", "not"
Predicates "null?", "true?", "false?", "string?", "list?", "contains?", "empty?"
List Functions "map", "apply", "list", "cons", "concat", "nth", "first", "last", "rest", "count", "empty?"
Object Functions "get", "set", "contains?", "keys", "vals"
String Functions "str", "pr-str", "prn", "println"
Other "throw"

Special Forms

Conditional ["if", [">", 3, 2], 7, 8]
Multiple Actions
(side-effects)
["do", ["prn", 123], 456]
Environment Bindings ["def", "x", 123]
["let", ["y", 456],
  ["*", 2, "y"]]
Quote ["`", ["prn", 123]]
Error Handling ["try", "abc",
  ["catch", "e",
    ["prn", "e"]]]

Metaprogramming

Macros ["def","unless",["~",["fn",["p","a","b"],
  ["list",["`","if"],"p","b","a"]]]]
Read ["read",["`", "[\"+\", 2,3]"]]
Eval ["eval",["`", ["+", 2,3]]]

JavaScript Interop

Evaluate JavaScript ["js", ["`", "2 + 3"]]
Method call [".", "Object",
  ["`", "keys"], {"a": 1}]
Get attribute [".-", "Math", ["`", "PI"]]
Set attribute [".-", "window",
  ["`", "location"],
  ["`", "http://github.com"]]
Delete attribute ["del", "window",
  ["`", "console"],
Object Class ["classOf", 123]
Inheritance Test ["isa", {}, "Object"]
Instantiate Object ["new", "Array", 3]