> ./lisp2d
Start without parameters enters into an interactive mode with the function read-eval-print.
This function supports necessary service traditional for Unix-consoles - editing with the keys: arrows left, right, backspace, delete, home, end and also listing history of the entered expressions with the keys arrows up and down.
> ./lisp2d filename [{ argi }]
Conseqently carries out all forms stored in a file filename. Before executing of a file a variable arg links with the list of strings ( "arg1" … "argn" ).
In all cases the received result of calculation comes back as a return code of the program if result was value of type char or integer, otherwise a return code - 0.
Interpreter uses a system multithreading, streams of the POSIX standard.
The quantity of working streams will be equal to quantity of processors. The quantity of calculations history records is 16.
The history of calculations at programming gives the big advantage. All knots of a course of the program are visible and the site in which there was an unexpected operation is visible. Speed of a program debugging increases 10 times.
(nil setdebug),(nil setdebug false),(nil setdebug 0) - cancels record in history of calculations. Speed of the program increases.
(nil setdebug number) - changes the size of history of calculations.
(nil getdebug) - returns the size of history of calculations.
(cerr error) - to see the history of calculations.
(obj … obj) - list
#(obj … obj) vector (array)
'obj=(nil quote obj) - prohibition of calculations.
'''(very
long
comment
('class defmethod m (x) …)) - it is used and as the comment of old functions
;abc…z - the comment up to the end of a line
`obj=(nil backquote obj) - back quote (partial prohibition of calculations)
,obj=(nil unquote obj) - calculation inside backquote
,@obj=(nil unquote-splicing obj) - calculation with an insert inside backquote
(obj . obj) - dot pair
&env - connects a variable with a context of the moment of a call of function ((lock . vector) … (lock . vector)). vector=#((symbol . value) … (symbol . value)).
nil nothing or empty list
true- The logic truth
false - The logic false
Global variables:
package - The variable, contacts a loaded file
arg - the variable, communicates with the list of the arguments transmitted at loading of a file.
pi=3.141592653589… π
e=2.718281828459…
cin - standard stream of input
cout - standard stream of an output
cerr - standard stream for error messages.
xk-enter, xk-home, xk-end, xk-left, xk-right, xk-up, xk-down, xk-page-up, xk-page-down, xk-insert, xk-delete, xk-caps-lock, xk-shift-l, xk-shift-r, xk-control-l, xk-control-r, xk-alt-l, xk-alt-r, xk-f1, xk-f2, xk-f3, xk-f4, xk-f5, xk-f6, xk-f7, xk-f8, xk-f9, xk-f10, xk-f11, xk-f12, xk-backspace, xk-undo, xk-num-lock, xk-kp-multiply, xk-space, xk-numbersign, xk-question - codes of the pressed keys for function (window read-keyb)
In objects:
this - value of itself (object)
(nil symbolp obj) - of conformity to a symbol
(nil numberp obj) - number
(nil objectp obj) - object of a class
(nil timep obj)
(nil dirp obj)
(nil bifp obj)
(nil lockp obj)
(nil signalp obj)
Symbols it is auxiliary object for programming, Pure Lisp have no symbols. They can have values: usual and functional, at them is present auxiliary properties.
(symb <> s1 … sn) – any symbol si is not equal symb
(symb = symb…symb), (symb < symb…symb), (symb <= symb…symb), (symb > symb…symb), (symb >= symb…symb) - comparisons (alphabetically).
(symb min symb … symb), (symb max symb … symb) - minimal/maximal (alphabetically).
(string|char symbol) - returns a symbol with a name string|char.
(symb properties) - returns all properties of a symbol as #((symb. value) …), pairs in vector are sorted on symb
(symb boundp) - whether symbol has a value. Returns a dot pair or false
(nil|symbol gensym) - Function-generator of the different symbols beginning on symbol if the initial symbol is not specified begins on T. It is guaranteed, that the returned symbol is new.
(nil progn b1 … bn) - consecutive calculation b1 … bn , returns result of calculation bn after calculation of all forms b1…bn.
(nil fork {tasks}) - creates parallel tasks tasks, does not expect their result and returns nil.
(nil let ((var1 {val1})|var1…(varn {valn})|varn) {body}) - creates in parallel local links of variables var with values val and consistently calculates the form body. Variables without value val are initialized with value nil.
(nil quote obj)='obj - calculation of obj is blocked.
(nil eval obj [env]) - double calculation. First obj it is calculated as argument of function eval , then returns the result of calculation by the interpreter of the received value. When arguments env are given, the second calculation will be made in a corresponding environment env.
(nil apply obj fn arglist [env]) - application of function fn to arguments arglist. Value of a variable fn can be a name or lambda-list. Arguments and object calculates only once.
(nil funcall obj fn [{arg}]) - application of function fn to arguments arg. Value of a variable fn can be a name or lambda-list. Arguments and object calculates only once.
(nil funcallenv env obj fn [{arg}]) - application of function fn to arguments arg. Value of a variable fn can be a name or lambda-list. Arguments and object calculates only once. Method calculation is made in an environment env.
(nil unquote obj)=,obj - insertion inside the form backquote.
(nil unquote-splicing obj)=,@obj - insertion with distribution inside the form backquote.
(stream error {mess}) - prints the message on a mistake mess. Wait pressing a key and returns nil.
(string load [arg1 … argn]) - reads out a file with a name string, calculates and returns corresponding result. Before calculation the variable arg links with the list of arguments (arg1 … argn) . After calculation the previous value arg is restored.
(string save obj) - writes down object obj in a format of writing in a file with a name string.
(nil do-while {body}) - cyclic calculation of the forms body if its last result will be nil or false calculations stop and result will be this value.
(nil while test {body}) consecutive conditional cycle. It is checked test, if test=false or nil then result will be this value. Then forms are consistently carried out body, then a step to check test.
(a = b … z) - equality a=b=…=z.
(n <> x1 … xk) - any number xi is not equal n .
(a < b … z) - numbers grow a<b<…<z.
(a > b … z) - numbers decrease a>b>…>z.
(a <= b … z) - less or equal(do not decrease) a≤b≤…≤z.
(a >= b … z) - bigger or equal(do not grow) a≥b≥…≥z.
At successful comparison the first argument a comes back.(x nanp) - predicate of 0/0.
(x infp) - predicate of ±∞.
(x finitep) - predicate of finite number, not ±∞ and not 0/0.
(numb min numb … numb), (numb max numb … numb) - the minimal/maximal number.
(x sin) - sine.
(x cos) - cosine.
(x tg) - a tangent.
(x ctg) - cotangent.
(x arcsin)=sin-1x
(x arccos)=cos-1x
(x arctg)=tg-1x
(x arctg y)=tg-1(x/y) ,y>0 ,x>0
(x sh)=(ex-e-x)/2
(x ch)=(ex+e-x)/2
(x th)=sh(x)/ch(x)
(x cth)=ch(x)/sh(x)
(x arsh)=sh-1x
(x arch)=ch-1x
(x arth)=th-1x
(x sqrt) - square root √x
(x cbrt) - cube root x1/3
(x exp) - exponent ex
(b ^ n) - a degree bn
(x log [a])=logax - the logarithm on the basis a (by default natural logarithm).
(x ln)=ln(x) - natural logarithm.
(x lg)=log10x - the decimal logarithm.
(x !)=1*2*…*x - a factorial.
(list second)=((list rest) first)
(list third)=(((list rest) rest) first)
(nil cons first rest) - creates a list cell with respective links.
('cons newobject first rest)=(nil cons first rest)
('cons newobject another-cons)=(another-cons copy)
('cons newobject)=(nil cons nil nil)
(nil list arg1 … argn) - returns the list of arguments (arg1 … argn), arguments are calculated in parallel
(list copy) - returns the new list. Cells of top level are copied only.
(list copy-tree) - returns a new tree. Cells, both first and rest are copied all.
(envir assoc who [testeql]) - returns a pair (obj . obj-value) from a list envir=((a . 1) (b . 2) … (c . 3)) at which who=obj if this pair there exists, and nil - at absence of value. By search predicates of equality of objects testeql, by default are used: =
(a-list acons x y)=(nil cons (nil cons x y) a-list) - adds in the associative list a pair (x . y), the result should be saved: ('a-list set (a-list acons x y))
(list = list … list) - comparisons of the contents of all lists
(list <> l1 … ln) - any list li is not equal list.
(list vector) - returns a new vector with elements of the list
(nil vector) - returns a new empty vector #()
(list count [{x}]) - quantity of units of the list satisfying to inquiry (elt = [{x}]).
(list count-if fn [{x}]) - quantity of units of the list satisfying to inquiry (elt fn [{x}]).
(vector elt i [j … [k]]) - returns an element of vectori,j,…,k. Elements of vector are numbered from 0 up to size-1
(vector copy) - returns a new vector.
(vector copy-matrix) - returns a new vector. If a unit - a vector it also is copied.
(vector vector dimlist [init])≈(vector setf ('vector newobject dimlist [init]))
(vector vector number [init])≈(vector setf ('vector newobject number [init]))
(vector vector another-vector)=(vector setf another-vector)
The vector of vectors means a matrix. The matrix is set by lines. The first element of a vector is the first line of the matrix, the second - the second, etc. Operations + , - , * are set in mathematical sense.
| R=M+N | Ri,j=Mi,j+Ni,j |
| R=M-N | Ri,j=Mi,j-Ni,j |
| R=m*N | Ri,j=m*Ni,j |
(vector count [{x}]) - quantity of units of a vector satisfying to inquiry (elt = [{x}]).
(vector count-if fn [{x}]) - quantity of units of a vector satisfying to inquiry (elt fn [{x}]).
(str size) - returns length of a string
('string newobject number [char]) - creates a string of the given size. It is filled by letters char, by default blanks.
('string newobject another-string)=(another-string copy)
('string newobject) → ""
(str0 = str1 … strn) equality str0=str1=…=strn
(str <> st1 … stk) - any string sti is not equal str
(str0 < str1 … strn), (str0 > str1 … strn), (str0 <= str1 … strn), (str0 >= str1 … strn) - on a code of characters (alphabet order)
(str min str … str), (str max str … str) - minimal/maximal
(str lower) returns a new string with letters in the bottom register
(str upper) returns a new string with letters in the top register
(str read) - converts a line in Lisp object (the built - in parser)
(string copy) - returns new string.
(string string number [char])≈(string setf ('string newobject number [char]))
(string string another-string)=(string setf another-string)
(string count [{x}]) - quantity of units of string satisfying to inquiry (elt = [{x}]).
(string count-if fn [{x}]) - quantity of units of string satisfying to inquiry (elt fn [{x}]).
(char0 = char1 … charn) equality char0=char1=…=charn
(char <> char1 … charn) – any chari is not equal char
(char0 <= char1 … charn) char0≤char1≤…≤charn
(char0 < char1 … charn) char0<char1<…<charn
(char0 > char1 … charn) char0>char1>…>charn
(char0 >= char1 … charn) char0≥char1≥…≥charn
(char min char … char), (char max char … char) - minimal / maximal
(number char) - returns a character with a code number
(ch code) - returns a code of a character ch
(ch alphap) - the letter in the top or bottom register #\a…#\z #\A…#\Z
(ch upperp) - the letter in the top register #\A…#\Z
(ch lowerp) - the letter in the bottom register #\a…#\z
(ch digitp) - #\0…#\9
(ch spacep) - character-divider
(ch controlp) - managing character (ASCII 0…31 or 127)
(ch printp) - whether it is possible to print out
(ch upper) - equivalent of the letter in the top register
(ch lower) - equivalent of the letter in the bottom register
It is used for exclusive access to the important sites of the program.
('lock newobject) - creates the lock.
(lock progn {body}) - the lock is put and consistently calculates tasks body. If the lock has been closed, its opening is expected.
(lock try task-locked task-free) - at successful installation of the lock the task-locked is calculated, differently task-free is calculated.
(lock set) - the lock is put. If the lock has been closed, its opening is expected. It is not recommended to use. The big danger of errors at programming.
(lock free) - the lock opening. It is not recommended to use. The big danger of errors at programming.
('signal newobject) - creates the object a signal.
(signal send) - dispatches a signal.
This technics of programming that is created that people could understand very big program physically. And the part of a code which has some functions of dialogue with other part of the program is called as object.
All built-in types have the class, it is possible to find out its name with the help of function (nil type-of obj).
(classname defclass) - minimal yet empty definition. Returns classname.
(classname defstatic varname startvalue) - adds a static field to a class. startvalue - is calculated and becomes common value for all objects of given class.
(classname defmacro macroname (… args …) {macrobody}) - adds a macro to a class.
(classname getmethod methodname) - returns definition of a method. methodname is calculated. If such method is not present, nil.
(classname getstatic staticname) - returns static field value of a given class. staticname is calculated.
(classname getclass) - returns definition of a class. If such class is not present, nil.
(nil type-of obj) - returns a symbol of a classname of object obj
Using:
(obj) → obj
(obj method arg1 … argn) - call of a method method of object obj.
(object copy) - returns new object.
There are three standard streams which are used by functions by default. They are stored in variables cin, cout and cerr.
(stream write obj … obj) - prints value of obj in convenient kind for viewing the person. Returns stream.
(stream princ obj … obj) - prints values obj as, suitable for input in the interpreter. Returns stream.
(stream writeln obj … obj) - calls function write and terminates a line. Returns stream.
(stream print obj … obj) - calls function princ and terminates a line. Returns stream.
| in | on reading |
| out | on writing |
| trunc | to cut down a file till zero length |
| app | addition in the end |
| ate | opening and search of the end of a file |
(string create)=(string open 'out 'trunc) - creates a new empty file with a name string and returns the stream connected with it for writing.
(stream close) - closes a stream.
(stream read) - reads from a stream string representation of object and returns Lisp2D object.
(stream read-char [char]) - reads 1 symbol from a stream. If it will be given char result it is placed there.
(stream read-byte [number]) - reads 1 byte from a stream and returns an integer. If the number is given result is placed there.
(stream listen) - returns true when in a stream not found out the symbol of the end of a file, else - false
(stream terpri) - writes a symbol of the end of a line to a stream stream
(stream write-byte integer) - writes to a stream 1 byte
(stream tellr) - returns an integer - a position of reading of a stream
(stream tellw) - returns an integer - a position of writing in a stream
Different names of functions are necessary for job with streams of reading+writing
(stream seekr number [mode]) - establishes a position of reading of a stream
| beg | from the beginning of a current file |
| cur | from a current position |
| end | from the end of a current file |
(stream flush) - clears the buffer of a stream.
(win close) - closes a window
Coordinates are defined from left to right and from top to down.

(nil mapwindow width height) – creates a window without monitoring in display.
(window-mapped open) – show the window on display.
(window openp) – is it open.
(window hide) – close the window. The image is keeped.
The drawing of the image with the closed window is much faster.
(win rename string) – gives a title to window.
(win move x y) transfers a window to coordinate (x y)
(win resize w h) changes the sizes of a window and a matrix of colors
(win width) - width of a window in pixels
(win height) - height of a window in pixels
(window listen) - interrogates a stream of pressing buttons of the keyboard at job in a window window . Returns a code of the letter or false . From turn of pressing it is not taken.
(window read-char [char]) - takes the letter from a stream of pressing buttons of the keyboard. If the queue is empty then expects. Returns the letter. If it will be given char result it is placed there.
(window keyb-event) - interrogates a signal of the keyboard on pressing/(pressing out) of keys of the keyboard. Returns nil or (code true|false).
(window pointer-coord) - returns local coordinates of the pointer as the list (x y).
(win getpixel x y) returns color of a point as (r g b), at coordinates outside a window returns (0 0 0)
(win draw-pixel col|(colr colg colb) x y x y … x y) - Draws points on the screen the set color [0…1] If color puts number will be a grey shade, differently ([0…1] [0…1] [0…1])=(red green blue)
At coordinate x the whole part undertakes only, are from 0 up to width-1
At coordinate y the whole part undertakes only, are from 0 up to height-1
Such sense of coordinates only for working with pixels.
At functions of a portrayal not for job with pixels of coordinate in a window it is numbers from a floating point from 0 up to width (height) . Start of functions of a portrayal at coordinates behind these limits does not result in a mistake and is ignored.
(win draw-square col|(colr colg colb) x y w h … x y w h) Draws the painted over rectangulars the set color [0…1] If color puts number will be a grey shade, otherwise ([0…1] [0…1] [0…1])=(red green blue)
By initial corner it is designated x y , width and height w h.
Coordinates for a portrayal in a window are set by numbers from a floating point from 0 up to width (height) . To paint over all window in one color it is possible to make it so:
(win draw-square col 0 0 w h).
To draw lines on edge of a window it is possible to use:
(win draw-square col 0 0 1 h 0 0 h 1 0 h w -1 w 0 -1 h)
To draw one point:
(win draw-square col x y 1 1)
If coordinates not the whole function draw-square smooths the image. Therefore it is possible to trace many small rectangulars and it gives effect to a half-transparency.
(nil let ((size 200) halfsize shift w (map 10) size/map)
(nil setq
halfsize (size / 2)
shift (size / 20)
size/map (size / map)
w (nil window (size + 1) (size + 1)))
((map + 1) for i
(w draw-square '(0 1 1)
0 (i * size/map) (size + 1) 1
(i * size/map) 0 1 (size + 1)))
(halfsize for i
(w draw-square '(1 0 0)
(i - shift) (i + shift) halfsize (i / halfsize)))
(halfsize for i
(w draw-square '(0 0 1)
(i + shift) (i - shift) (i / halfsize) halfsize))
(cout write "press a key...")
(w read-keyb)
(w close))

(win draw-line col|(colr colg colb) radius x y x y … x y) - draws lines on the screen the set color [0…1] If color puts number will be a grey shade, differently ([0…1] [0…1] [0…1])=(red green blue). radius - sets thickness of a line, more precisely radius.
It is intended for easing an overload of names of functions and constants.
It is recommended to define functions and variables in personal space as if to use other programs and they will redefine function with the same name - that access up to it is impossible.
('name namespace {body}) - connects all constants and functions determined in the given space of names and the body body is carried out consistently.
To define these constants very simply:
('version1 namespace
('conste letset 1000)
(nil defmethod m (x)
(cout write "x=" x)))
('version1 namespace
(nil m conste))
From the outside this space it is impossible to use them:
conste → error
(nil m 1) → error
Almost all functions of language are determined in space of names std and it is possible to cause these functions with the overloaded definition by other programs so:
('another namespace
('number defmethod ! () (cout write "another"))
…
('std namespace
(3 !) → 6
…)
…)
The class of objects time which have methods is defined.
To work with directories there is a class dir.
(dir open string-path) - opening of the directory.
(dir openp) - is it opened or not.
(dir close) - directory closing.
(dir read) - returns a string or nil(if files have ended).
(dir rewind) - cross to the beginning of the directory.
(string rmdir) - deletes the empty catalogue.
(string unsetenv) - reset of value of the variable environment
(nil geteuid) - number, of the identifier of the user
(nil getegid) - number, of the identifier of group
The user root has number of the identifier 0
(nil sysname) - string, name of operational system, for example "Linux"
(string-oldpath link string-newpath) - creation of the rigid reference to a file, not being the catalogue.
(string-oldpath symlink string-newpath) - creates symbolic link.
(string-path readlink) - returns a string of a contents of the symbolic link.
(string unlink) - deletes a file/removes membership in the catalogue
(nil nprocs) - number, quantity of processors of system
(string truncate size) - changes the size of a file with a name string. At unsuccessful change comes back nil.
(string blkp) - is a special file of the block device.
(string chrp) - is a special file of the symbolical device.
(string dirp) - is the catalogue.
(string fifop) - is the called or not called channel.
(string lnkp) - is the symbolical reference.
(string regp) - is a usual file.
(string sockp) - is a socket.
(string usrreadp)
(string setusrreadp flag)
(string usrwritep)
(string setusrwritep flag)
(string usrexecp)
(string setusrexecp flag)
(string grpreadp)
(string setgrpreadp flag)
(string grpwritep)
(string setgrpwritep flag)
(string grpexecp)
(string setgrpexecp flag)
(string othreadp)
(string setothreadp flag)
(string othwritep)
(string setothwritep flag)
(string othexecp)
(string setothexecp flag)
(string uidp) - the right to change of the identifier of the user at execution.
(string setuidp flag)
(string gidp) - the right to change of the identifier of group at execution.
(string setgidp flag)
(string vtxp) - the limited mode of removal from the catalogue.
(string setvtxp flag)
(number-uid uname) - user name (login).
(number-uid gid) - the numerical identifier of group by default.
(number-uid home) - string, home directory.
(number-uid shell) - command interpreter by default.
(number-gid gname) - group name.
(number-gid gmem) - group members.
(nil getlogin) - the string, user name.
&env
&rest
&whole
#\backspace
#\delete
#\down
#\end
#\enter
#\escape
#\home
#\left
#\right
#\space
#\tab
#\up
!
+ list
+ number
+ string
+ symbol
+ vector
+= cons
+= number
+= string
+= vector
- number
- symbol
- vector
-= number
-= vector
* number
* vector
*= number
*= vector
/
/=
= char
= cons
= false
= nil
= number
= string
= symbol
= true
= vector
<> char
<> cons
<> false
<> nil
<> number
<> string
<> symbol
<> true
<> vector
< char
< number
< string
< symbol
<= char
<= number
<= string
<= symbol
> char
> number
> string
> symbol
>= char
>= number
>= string
>= symbol
%
^
abs
accessf
accessr
accesstime
accessw
accessx
acons
alphap
and
apply
arch
arccos
arcsin
arctg
arg
arsh
arth
assoc
atom
backquote
bavail
bfree
bifp
blkp
blocks
blocksize
boundp
button-event
cbrt
ceil
cerr
ch
changetime
char char
char number
charp
chdir
chrp
cin
close dir
close stream
close window
code
combin
combina
cond
cons nil
cons cons
consp
contain list
contain string
contain vector
controlp
copy char
copy dir
copy list
copy number
copy object
copy string
copy time
copy vector
copy-matrix
copy-tree
cos
count list
count string
count vector
count-if list
count-if string
count-if vector
cout
create
ctg
cth
day
daylightp
defclass
defmacro
defmethod
defstatic
defvar
degrees
denom
device
digitp
dir
dirp
display-size
display-sizemm
do-while
draw-line
draw-pixel
draw-square
dstp
e
elt string
elt vector
empty
environ
eq
error
eval
evenp
exp
false
favail
ffree
fifop
files
find list
find string
find vector
find-if list
find-if string
find-if vector
finitep
first cons
first vector
floor
flush
for list
for number
for string
for vector
for* list
for* number
for* string
for* vector
fork
free
freeram
frsize
fsid
funcall
funcallenv
gcd
gensym
get
getclass
getcwd
getdebug
getegid
getenv
geteuid
getlogin
getmethod
getpixel
getstatic
gid number
gid string
gidp
gmem
gname
grpexecp
grpreadp
grpwritep
height
hide
home
hour
if
infp
inode
insert
integerp
keyb-event
last cons
last vector
lcm
let
letset
lg
link
links
list nil
list string
list vector
list*
listen stream
listen window
listp
ln
lnkp
load
localtime
lockp
log
lower char
lower string
lowerp
ls
machine
map cons
map vector
mapc cons
mapc vector
mapwindow
max char
max number
max string
max symbol
merge
min char
min number
min string
min symbol
minutes
mkdir
modifytime
month
move window
multinomial
namemax
namespace
nanp
newobject char
newobject cons
newobject dir
newobject lock
newobject number