LISP vs WolframLang
The major influence of WolframLang is LISP and APL. 〔see LISP / APL Root in Wolfram Language〕
LISP in WolframLang
WolframLang has all the characteristics of LISP:
- Identifiers are Symbols
- Everything is a Expression
- A expression is either a Atomic Expression (number, string, symbol) or a list.
- Purely nested syntax
- Predominantly functional programing
- Reader macro (meta-expression) (lisp
[] ' ` , # ,@ .
vs WolframLang syntax shortcuts ) - Lisp macros (WolframLang symbolic Pattern Matching)
APL in WolframLang
APL's contribution to WolframLang are:
- All APL's functions are in WolframLang.
- Function automatically map to array, when input is array (matrix or list).
Here's a table of comparison of LISP and WolframLang.
Syntax
LISP | WolframLang |
---|---|
(f a b c)
|
f[a, b, c]
|
; comment
|
(* comment *)
|
Expression Grouping
LISP | WolframLang |
---|---|
progn
|
CompoundExpression
or ;
|
Arithmetic
LISP | WolframLang |
---|---|
+
|
Plus or +
|
-
|
Minus or -
|
*
|
Times or *
|
/
|
Divide or /
|
%
|
Mod
|
expt
|
Power or ^
|
floor
|
Floor
|
ceiling
|
Ceiling
|
round
|
Round
|
Boolean, Equality Test
LISP | WolframLang |
---|---|
t |
True
|
nil
|
False
,
Null
|
and
|
And
or
&&
|
or
|
Or
or
||
|
not
|
Not
or
!
|
>
|
Greater
or
>
|
>=
|
GreaterEqual
or
>=
|
<
|
Less
or
<
|
<=
|
LessEqual
or
<=
|
= , eq , equal , string-equal
|
Equal
or
== ,
SameQ
or
=== ,
|
Variable and Assignment
LISP | WolframLang |
---|---|
setq ,
seq-setq ,
setf ,
set
|
Set
,
SetDelayed
|
let ,
let*
|
Module ,
Block ,
With .
|
Flow Control
LISP | WolframLang |
---|---|
if
|
If
|
cond
|
Which ,
Switch
|
throw
,
catch
|
Throw
,
Catch
|
error
|
Abort
|
Loop, Iteration
LISP | WolframLang |
---|---|
while
|
While
|
mapcar
|
Map
|
mapc
|
Scan
|
dotimes
|
Do
|
Data Structure
LISP | WolframLang |
---|---|
list , vector
|
List
|
association list, hash table |
Association
|
Function
LISP | WolframLang |
---|---|
defun , lambda
|
Function
|
defmacro
|
SetDelayed
|
funcall , apply
|
Apply
|
Input Output
LISP | WolframLang |
---|---|
print
|
Print
|
Package, Namespace, Loading
LISP | WolframLang |
---|---|
load
|
Get
|
require
|
Needs
|
features
|
$ContextPath
|
autoload
|
DeclarePackage
|
Reader Macro, Evaluation Control
LISP | WolframLang |
---|---|
quote ,
' ,
`
|
Hold
,
HoldComplete
|
eval
,
,
|
Evaluate
|
,@
|
Sequence
|