# Operator Index

## Infix operators

The following list gives an overview of Special Character Operators ordered by precedence. Precedece is given as a number. The lower the number the higher the binding. Operators of equal precedence are applied from left to right, i.e. Special Character Operators are left-associative.
`:` (20) access to self defined
`.` (25) access to predefined data field
`°` (25) degree operator
`_` (50) access to element in list
`^` (50) power operator
`*` (100) multiplication (also of vectors and matrices)
`/` (100) division (also of vectors and matrices by scalars)
`+` (200) addition (also of vectors and matrices by scalars)
`-` (200) subtraction (also of vectors and matrices by scalars, binary and unary)
`!` (200) logic not (unary)
`==` (300) equal
`>` (300) greater
`<` (300) smaller
`>=` (300) greater or equal
`<=` (300) smaller or equal
`!=` (300) not equal
`~=` (300) approximately equal
`~<` (300) approximately smaller
`~>` (300) approximately greater
`~>=` (300) approximately greater or equal
`~<=` (300) approximately smaller or equal
`=:=` (300) equal after evaluation
`&` (350) logic and
`%` (350) logic or
`!=` (350) not equal
`~!=` (350) approximately not equal
`..` (350) list of numbers from/to
`++` (370) concatenation of lists
`--` (370) list difference
`~~` (370) common elements of two lists
`:>` (370) append element to list
`<:` (370) prepend element to list
`=` (400) variable assignment
`:=` (400) function definition
`:=_` (400) clearing a definition
`->` (400) modifier declaration
`,` (500) separator for lists and functions
`;` (500) separator for statements
In what follows we specify Cinderella's predefined functions. After the function name, the number of arguments is indicated in brackets. For easier reference, the functions are grouped in a few categories. Some functions may appear in several categories. Light blue functions are not documented yet.

### Basic Functionality

#### Control structures

`if` (2) if operator
`if` (3) if/else operator
`trigger` (2) trigger a function on value change
`while` (2) while loop
`repeat` (2) repeat loop with # run-variable
`repeat` (3) repeat loop with explicit run-variable
`forall` (2) repeat loop with # run-variable
`forall` (3) forall loop with explicit run-variable
`eval` (1) force evaluation of an expression

#### Variable management

`clear` (0) clear all variables
`clear` (1) clear a specific variable
`keys` (1) list of local keys associated with an object or a variable
`createvar` (1) create a local variable
`removevar` (1) destroy a local variable
`regional` (arbitrary many arguments) create local variables
`local` (arbitrary many arguments) create local variables (deprecated)
`release` (arbitrary many arguments) remove local variables and return last value (deprecated)

#### Output

`print` (1) print a value
`println` (0) newline
`println` (1) print a value followed by newline
`clearconsole` (0) clear the output console
`err` (1) debugging printout
`assert` (2) conditional print for error checking
`format` (2) convert a number to a string with specified precision
`message` (1) show a message in the status line

### Calculations

#### Arithmetic functions

`sqrt` (1) square-root
`exp` (1) exponential function
`log` (1) natural logarithm
`sin` (1) sine function
`cos` (1) cosine function
`tan` (1) tangent function
`arcsin` (1) arcsine function
`arccos` (1) arccosine function
`arctan` (1) arctangent function
`arctan2` (1) binary arctangent function
`arctan2` (2) binary arctangent function
`add` (2) addition
`sub` (2) subtraction
`mult` (2) multiplication
`div` (2) division
`mod` (2) modulo
`pow` (2) power
`abs` (1) absolute value
`round` (1) rounded value
`floor` (1) closest smaller integer
`ceil` (1) closest larger integer
`re` (1) real part
`im` (1) imaginary part
`conjugate` (1) complex conjugate
`random` (1) random real number
`randominteger` (1) random integer number
`random` (0) random number between 0.0 and 1.0
`randombool` (0) random boolean value
`randomnormal` (0) (0,1)-normal distributed random real value
`seedrandom` (1) seed the random generator

#### Boolean functions

`not` (1) logical not
`and` (2) logical and
`or` (2) logical or
`xor` (2) logical exclusive or

#### Predicates

`isinteger` (1) test for integer
`isreal` (1) test for real number
`iscomplex` (1) test for complex number
`iseven` (1) test for even integer
`isodd` (1) test for odd integer
`islist` (1) test for list
`ismatrix` (1) test for nested list in matrix shape
`isnumbervector` (1) test for list which is a number vector
`isnumbermatrix` (1) test for list which is a number matrix
`isstring` (1) test for string
`isgeometric` (1) test for geometric object
`isselected` (1) test for being selected
`ispoint` (1) test for point
`isline` (1) test for line
`iscircle` (1) test for circle
`isconic` (1) test for conic
`ismass` (1) test for mass
`issun` (1) test for sun
`isspring` (1) test for spring
`isundefined` (1) test for being undefined

#### String functions

`text` (1) convert anything to a string
`substring` (3) substring of a string from start index to end index
`replace` (3) replace all occurences of a substring by another string
`replace` (2) apply several replacements given in a list of replacement pairs
`tokenize` (2) tokenize a string and return a list of tokens
`indexof` (2) first index of a substring
`indexof` (3) first index of a substring after position
`length` (1) length of a string
`format` (2) convert a number to a string with specified precision
`sort` sort elements from a list, can in particular be applied to lists of strings
`fontfamilies` (0) a list of all available fonts
`unicode` (1) convert unicode into character
`candisplay` (1) test if a string can be rendered by the current system and font
`guess` (1) convert a number to a string guessing the numbers meaning
`parse` (1) convert string to CindyScript expression

#### Calculus

`d` (2) numerically differentiate a function
`tangent`(2) calculate the tangent to a function
`guess` (1) convert a number to a string guessing the numbers meaning
`pslq` (1) same as `guess`
`roots` (1) determine the roots of a polynomial

### Lists and Linear Algebra

#### Elementary list operations

`take` (2) access the n-th element of a list
`length` (1) length of a list
`contains` (2) predicate for membership
`append` (2) append an element to a list
`prepend` (2) prepend an element to a list
`concat` (2) concatenate two lists
`common` (2) common elements of two lists
`remove` (2) list difference

#### Traversing lists

`forall` (2) forall loop with # run-variable
`forall` (3) forall loop with explicit run-variable
`apply` (2) apply a function to all elements of a list (run variable is #)
`apply` (3) apply a function to all elements of a list (explicit run variable)
`select` (2) select all elements of a list with a certain property (run variable is #)
`select` (3) select all elements of a list with a certain property (explicit run variable)

#### High-level list operations

`pairs` (1) list of all pairs of elements of a list
`triples` (1) list of all triples of elements of a list
`directproduct` (2) direct product of two lists
`consecutive` (1) list of all pairs of consecutive elements of a list
`cycle` (1) list of all pairs of consecutive elements of a list, cyclically closed
`reverse` (1) reverse a list
`set` (1) remove multiple instances of list elements, yielding a set
`sort` (1) sort elements in a list
`sort` (2) sort elements in a list by explicit function
`flatten` (1) flatten the nesting depth of a list

#### Lists of geometric objects

`allelements` (0) all elements of a construction
`allpoints` (0) all points of a construction
`alllines` (0) all lines of a construction
`allsegments` (0) all segments of a construction
`allcircles` (0) all circles of a construction
`allconics` (0) all concics of a construction
`allmasses` (0) all masses of a simulation
`allsprings` (0) all springs of a simulation

#### Arithmetic list operations

`sum` (1) sum of all list elements
`sum` (2) sum of function values applied to all list elements (run variable is #)
`sum` (3) sum of function values applied to all list elements (explicit run variable)
`product` (1) product of all list elements
`product` (2) product of function values applied to all list elements (run variable is #)
`product` (3) product of function values applied to all list elements (explicit run variable)
`min` (1) minimum of all list elements
`min` (2) minimum of function values applied to all list elements (run variable is #)
`min` (3) minimum of function values applied to all list elements (explicit run variable)
`max` (1) maximum of all list elements
`max` (2) maximum of function values applied to all list elements (run variable is #)
`max` (3) maximum of function values applied to all list elements (explicit run variable)

#### Vector and matrix operations

`zerovector` (1) create a zero vector of specified length
`zeromatrix` (2) create a zero matrix of specified length
`rowmatrix` (1) convert a vector to a row matrix
`columnmatrix` (1) convert a vector to a column matrix
`matrixrowcolumn` (1) number of rows and colums of a matrix
`row` (2) a specific row of a matrix
`column` (2) a specific column of a matrix
`submatrix` (2) a specific minor of a matrix
`transpose` (1) transpose of a matrix
`dist` (2) numerical value of the distance of two vectors.
`det` (1) determinant of a square matrix
`hermiteanproduct` (2) hermitian scalar product
`inverse` (1) inverse of a square invertible matrix
`adj` (1) adjunct of a square matrix
`eigenvalues` (1) eigenvalues of a square matrix
`eigenvectors` (1) eigenvectors of a square matrix
`linearsolve` (2) solve a system of linear equations
`convexhull3d` (1) convex hull of a list of 3D points

### Drawing

#### Drawing functions

`draw` (1) draw a point
`draw` (2) draw a segment
`drawpoly` (1) draw polygon border from pointlist
`drawpolygon` (1) same as `drawpoly`
`fillpoly` (1) draw filled polygon from pointlist
`fillpolygon` (1) same as `fillpoly`
`drawcircle` (2) draw a circle from center and radius
`fillcircle` (2) fill a circle from center and radius
`drawall` (1) draw all elements in a list
`connect` (1) connect a list of points
`drawtext` (2) draw a string
`drawtable` (2) draw a table
`repaint` (0) force a repaint of the screen
`repaint` (1) force a repaint after a delay

#### Drawing appearance

`pointsize` (1) set point size
`linesize` (1) set line size
`textsize` (1) set text size
`pointcolor` (1) set point color
`linecolor` (1) set line color
`textcolor` (1) set text color
`color` (1) set overall color
`alpha` (1) set overall alpha
`gsave` (0) store colors, alpha, width, clip, and transformation to stack
`grestore` (0) restore colors, alpha, width, clip and transformation from stack
`greset` (0) reset colors, alpha, width, clip and transformation. Reset stack

#### Color functions

`red` (1) red RGB-vector
`green` (1) green RGB-vector
`blue` (1) blue RGB-vector
`grey` (1) grey RGB-vector
`gray` (1) gray RGB-vector
`hue` (1) hue RGB-vector

#### Function plotting

`plot` (1) plot a function with # run variable
`plot` (2) plot a function with explicit run variable
`fillplot` (1) plot a function with integral like highlighting
`fillplot` (2) highlight the difference between two functions
`colorplot` (3) plot a region colored by the values of a function
`drawfield` (1) draw the flux of a vector field
`drawfieldcomplex` (1) draw the flux of a complex function
`drawforces` (1) draw the flux of a force field
`drawcurves` (2) draw an oscillograph for physics
`mapgrid` (1) mapping a rectangular grid

#### Pixelgraphics

`drawimage` (2) draw a pixelimage, w.r.t. one point
`drawimage` (3) draw a pixelimage, w.r.t. two points
`drawimage` (4) draw a pixelimage, w.r.t. three points
`drawimage` (5) draw a pixelimage, w.r.t. four points
`mapimage` (2) map a pixelimage, w.r.t. a function
`imagesize` (1) getting the size of an image
`imagergb` (3) inquiring the rgba value of a pixel
`createimage` (3) create a pixelimage with name and specified size
`clearimage` (1) erasing a pixelimage
`removeimage` (1) removing a pixelimage
`canvas` (3) using a pixelimage as canvas w.r.t. one point
`canvas` (4) using a pixelimage as canvas w.r.t. two points
`canvas` (5) using a pixelimage as canvas w.r.t. three points

#### Shapes

`circle` (2) create a circular shape from point and radius
`polygon` (1) create a polygonal shape from a list of points
`halfplane` (2) create a halfplane shape
`screen` (0) create a polygonal shape that covers the screen
`fill` (1) fill a shape
`draw` (1) draw the outline of a shape
`clip` (1) set clippath to a shape

#### Geometric transformations

`translate` (1) translate the global coordinate system
`rotate` (1) rotate the global coordinate system
`scale` (1) scale the global coordinate system
`setbasis` (1) set global coordinate system to a translation basis
`setbasis` (2) set global coordinate system to a similarity basis
`setbasis` (3) set global coordinate system to an affine basis
`setbasis` (4) set global coordinate system to a projective basis

#### Layer

`autoclearlayer` (2) automatic clearing of layers
`clearlayer` (1) clearing a layer
`clrscr` (0) remove all drawings in a layer
`layer` (1) setting the drawing layer
`screenbounds` (0) determining screen bounds
`screenresolution` (0) determining screen resolution

### Geometry

#### Geometric Functions

`moveto` (2) move point to position
`meet` (2) intersection of two lines
`join` (2) join of two points
`perp` (1) perpendicular 2-dimensional vector
`perp` (2) perpendicular of line through point
`perpendicular` (2) perpendicular of line through point
`para` (2) parallel of line through point
`parallel` (2) parallel of line through point
`cross` (2) cross-product of two 3-dimensional vectors
`dist` (2) distance of two points
`area` (3) area of triangle given by three points
`det` (3) determinant of matrix of three points in homogeneous coordinates
`crossratio` (4) cross-ratio of four points
`complex` (1) convert xy-point to complex number
`gauss` (1) convert complex number to xy-point
`point` (1) set the geometric type of a vector to point
`line` (1) setting the geometric type of a vector to line
`geotype` (1) retrieve the geometric type of a vector
`map` (2) obtain a transformation matrix for translations
`map` (4) obtain a transformation matrix for similarities
`map` (6) obtain a transformation matrix for affine transformations
`map` (8) obtain a transformation matrix for projective transformations
`pointreflect` (1) obtain a transformation matrix for reflection in a point
`linereflect` (1) obtain a transformation matrix for reflection in a line
`incidences` (1) list of incidences of a geometric object
`locusdata` (1) list of points on a locus

#### Inspection

`inspect` (1) list available attributes
`inspect` (2) get an attribute
`inspect` (3) set an attribute

#### Construction manipulation

`createpoint` (2) create a point with name and position (since 2.1)
`create` (3) create a an arbitrary geometric element
`removeelement` (1) delete a named geometric element and the dependent elements of it
`algorithm` (1) Getting the construction algorithm of an element
`inputs` (1) Getting the defining objects of an element
`element` (1) Getting a handle to an element

### Sound

#### MIDI

`playtone` (1) playing a MIDI note
`stoptone` (1) muting a MIDI note
`playfrequency` (1) playing a MIDI note with specified freqeuncy
`playmelody` (1) playing a MIDI melody given by a list of notes
`midiaddtrack` (1) assigning a MIDI melody given by a list of notes to a track
`midistart` (0) starting the MIDI tracks
`midistop` (0) halting the MIDI tracks
`midispeed` (1) setting the speed of the MIDI tracks
`midispeed` (0) getting the speed of the MIDI tracks
`midiposition` (1) setting the sound pointer
`midiposition` (0) getting the sound pointer
`instrument` (1) specifying a MIDI instrument
``instrumentnames` (0) list all available MIDI instruments`
`midichannel` (1) setting the midi channel
`midivolume` (1) setting the midi volume
`midicontrol` (2) setting an arbitrary midi control value

#### Sampled Audio

`playsin` (1) play a periodic signal
`playfunction` (1) use a function to generate an audio sample
`playwave` (1) use a list of numbers to generate an audio sample
`stopsound` (0) stop all sample out lines

### System functions

#### Mouse and key input

`mover` (0) last moved object
`mouse` (0) current mouse position in homogeneous coordinates
`elementsatmouse` (0) lists all elements close to the current mouse position
`key` (0) typed character
`iskeydown` (1) asks if a key is currently pressed
`keydownlist` (0) list of all kurrently pressed keys
`amsdata` (0) data from a built-in gravity sensor
`calibratedamsdata` (0) data from a built-in gravity sensor after calibration
`createtool` (3) creating a custom toolbar
`removetool` (1) removing a tool from a custom toolbar

#### Time

`resetclock` (0) reset the internal clock
`seconds` (0) seconds since last reset
`simulationtime` (0) time synchronized with simulation
`time` (0) current real-world time
`date` (0) current real-world date
`wait` (1) wait for a specified number of milliseconds

#### File IO

`setdirectory` (1) set current directory
`load` (1) load data from a file
`import` (1) import program code from file
`openfile` (1) open a file with specified name, return a handle
`closefile` (1) close a file given by a handle
`print` (2) print to a file
`println` (2) println to a file
`setdirectory` (1) set the current directory

#### Networking

`openurl` (1) open a specified URL in a browser
`javascript` (1) calling javascript
`openconnection` (2) open a TCP port
`print` (2) write to a TCP connection
`println` (2) write to a TCP connection
`flush` (1) flush output to a TCP port
`readln` (1) read from a TCP connection
`closeconnection` (1) close a TCP connection

### Physics and Animations

#### Physics simulation

`simulation` (0) handle to simulation
`force` (1) probing force at a specific position
`addforce` (2) apply a force to a mass
`setforce` (2) set the force of a mass to a specific value

#### Animations

`playanimation` (0) start the animation
`pauseanimation` (0) pause the animation
`stopanimation` (0) stop the animation

### Other

#### Experimental and Undocumented Operators

Use of the following operators is at your own risk.
`freevariables` (1)
`java` (1)
`curview` (0)
`curkernel` (0)
`curgraphalgorithm` (0)
`attribute` (2) read user attribute
`attribute` (3) set user attribute
`inspectinfo` (2) information on attribute
`createmass` (3) create a mass-point with name and position and velocity (currently not supported)

Page last modified on Monday 14 of July, 2014 [08:38:11 UTC].
The original document is available at http://doc.cinderella.de/tiki-index.php?page=Operator%20Index