[main]
MC2 Lisp functor categories:

@control
@sheet
@short datatype ops
@math
@formula operators
@string ops
@user interface
@help

@lisp notation

@worksheet expressions

[lisp notation]
We use the following notation:

(functor arg1:type [arg2:type]) -> result:type

functor takes 1 or 2 argumets (the second is optional) of type 'type'.

Data types can be:

+ boolean (true/false)
+ short (ex.:123)
+ long (123L)
+ float (1.23)
+ string ("this is a string")

+ nil
+ quoted list '(add 1 2)

Combined atoms:

+ date
@date
+ sheet
@sheet-create
+ cell
@cell-create
+ rowcolumn
@rowcolumn
... and so on

+ 'any' used if any argument type is allowed (including s-exp)

For math WS (WorkSheet formula) operators which can take short/long/float we use 'numeric' datatype.

+ reference
@ref

[worksheet expressions]
TBD
some examples:
=#DD/MM/YYYY#+sum(A1:$B$2)

[control]
Functors to handle program flow

@if
@while
@setq
@defun
@load
@module-load
@isnil

[if]
(if cond do-true do-else) -> any
ex.: (if (lt a 2) "a less 2" "a greater or equal 2")
[while]
(while cond do-true) -> nil
ex.: (setq stop true)(setq a 0)(while stop (setq a (add a 1)) (setq stop (lt a 10))
[setq]
(setq name1 value1 name2 value2)
Assigns values to names
[defun]
(defun funcname (arg1 argn) body) -> nil
Defines new functor (UDF)
ie.: (defun testfunc (x) (mul x x))
[load]
(load filename:string) -> any
Parses and interpretes lisp source code from .jar. Returns result of evaluation (the last item for a quoted list)
[module-load]
(module-load filename:string) -> alpha
Loads module (add-on) from java .class file. Returns some kind of alpha function associated with the names exported by module
[isnil]
(isnil s-exp) -> boolean
Evaluates s-exp and tests if it's 'nil'

[short datatype ops]

faster than ordinary ops, WS, as they don't check and convert arguments to same datatype.
@math

arithmetic:
@sadd
@ssub
@smul
@sdiv

comparison:
@sgt
@sge
@slt
@sle
@seq
@sne

[sadd]
(sadd short short) -> short
[ssub]
(ssub short short) -> short
[smul]
(smul short short) -> short
[sdiv]
(sdiv short short) -> short

[sgt]
(sgt short short) -> boolean
[sge]
(sge short short) -> boolean
[slt]
(slt short short) -> boolean
[sle]
(sle short short) -> boolean
[seq]
(seq short short) -> boolean
[sne]
(sne short short) -> boolean

[formula operators]
These functors are produced by WS formula parser. 
They can be used in Lisp code as well.
They can use arguments of short/long/float datatypes.

arithmetic:
@add
@sub
@mul
@div

comparison:
@eq
@ne
@le
@lt
@ge
@gt

pseido:
@umin
@parenthis

[add]
'+' operator
(add numeric numeric) -> numeric
[sub]
'-' operator
(sub numeric numeric) -> numeric
[mul]
'*' operator
(mul numeric numeric) -> numeric
[sub]
'*' operator
(div numeric numeric) -> numeric

[eq]
'=' operator
(eq numeric numeric) -> boolean
[ne]
'!=' operator
(ne numeric numeric) -> boolean
[lt]
'<' operator
(lt numeric numeric) -> boolean
[le]
'<=' operator
(le numeric numeric) -> boolean
[gt]
'>' operator
(gt numeric numeric) -> boolean
[ge]
'>=' operator
(ge numeric numeric) -> boolean
[umin]
'-' unary minus
(umin numeric) -> numeric
[parenthis]
'(' ')' - evaluation order (as MC doesn't handle this automatically), used only for print
(parenthis numeric) -> numeric

[math]

These functions can take ONLY float args.

basic arithmetic:
@fadd
@fsub
@fmul
@fdiv

@pow
@sqrt
@log
@exp

trigonometric:
@sin
@cos
@tan
@cot
@asin
@acos
@atan
@atan2

misc:
@round
@totype
@sum

constants:
@PI
@E

[fadd]
(fadd float float) -> float
[fsub]
(fsub float float) -> float
[fmul]
(fmul float float) -> float
[fdiv]
(fdiv float float) -> float

[pow]
z = x^y
(pow x:float y:float) -> z:float
[sqrt]
(sqrt float) -> float
[log]
(log float) -> float
[exp]
y = E^y
(exp x:float) -> y:float

[sin]
(sin float) -> float
[cos]
(cos float) -> float
[tan]
(tan float) -> float
[cot]
(cot float) -> float
[asin]
(asin float) -> float
[acos]
(acos float) -> float
[atan]
(atan float) -> float
[atan2]
(atan2 float float) -> float

[round]
rounds 'x' to 'prec' digits after the dot 
(round x:float prec:short) ->float
[totype]
converts to 'type'
(totype x:any type:short) -> y:type
[sum]
Sums arguments
(sum numeric reference ...)
WS: =sum(12.3,234L,1,A1:B2)
lisp: (sum 12.3 234L 1 ref(0 0 1 1 0))

