Index

Manual

Binary operator

@

An indexer suitable to be used on structures having elements identified with one index, such as arrays and strings. A matrix requires two indices to access an element (a row and column number), and can therefore not be used with this operator.

Example

2@"abc"; /* returns "b". */ 3@{3, 2, 1}; /* returns 1. */

See also

get

No-op

]

See also

[

Postfix unary operator

^T

The transpose of a matrix.

Example

[[1, 2], [3, 4]]^T

Binary operator

^

Raises the left argument to the power of the right argument.

Function

[

Creates a matrix.

Example

[32, 42]; /* Creates a 2x1 matrix. */ [[33], [41]]; /* Creates a 1x2 matrix. */ [[1, 2], [3, 4]]; /* Creates a 2x2 matrix. */

Value

false

A real constant containing zero, which is used as boolean false.

See also

true

Prefix unary operator

floor

Maps a real number to the largest integer not greater than the argument.

See also

ceil

Prefix unary operator

fpart

The fraction part of a real number.

See also

ipart

Function

frac

Creates a fraction.

Example

frac(1, 2); frac(3.5);

See also

den, num

Function

fill

Fills a matrix with a number.

Example

fill([0, 0], 23)

Function

for

The for loop executes an expression repeatedly as long as a condition is true. This loop is similar to the while loop, but contains an explicit iteration variable.

The following example prints the numbers from one to ten. The loop uses the variable x, which is initialized to 1 and incremented after each iteration.

for x := 1; x <= 10; x inc 1 do print x end

See also

while, repeat, if

Function

gramschmidt

Performs the Gram-Schmidt process on a matrix.

Function

gcd

Returns the greatest common divisor for a set of integers.

See also

lcm

Function

get

An indexer used to access elements in structures such as arrays and matrices.

Example

mx := [[1, 2], [3, 4]]; get(mx, 2, 2) := 23; /* replaces 4 with 23. */

Postfix unary operator

degrees

Converts a number from degrees to radians.

Example

print 180 degrees;

See also

radians

Prefix unary operator

den

Returns the denominator of a fraction.

See also

num

Binary operator

dec

Decrement operator.

Example

x := 2; x dec 1; /* x is now 1. */

See also

inc

Prefix unary operator

det

The determinant of a matrix.

No-op

do

See also

while, for

Postfix unary operator

!

Factorial.

The factorial of a non-negative integer n is the product of all non-negative integers <= n. 0! is defined to be one.

Example

print 7! /* prints 5040. */

See also

nCr, nPr

Function

echelon

Reduces a matrix to echelon form. Expects at least one argument (the matrix to be reduced), and optionally a second argument (the augmentation matrix). Returns an array containing the echelon matrix, and the result of the augmentation if it was supplied.

Prefix unary operator

execute

Locates and executes a script or an MComp.

Example

execute 'snake'

No-op

else

See also

if

No-op

elif

See also

if

Prefix unary operator

exit

Exits Calclipse with a status code.

Example

exit 0

Prefix unary operator

exp

The exponential function (e^x).

No-op

end

See also

if, while, for, repeat

Value

e

The base of the natural logarithm (2.7182...).

See also

exp, ln

Binary operator

cross

The cross product of two vectors.

Prefix unary operator

cbrt

Cube root.

Prefix unary operator

cosh

Hyperbolic cosine.

Prefix unary operator

ceil

Maps a real number to the smallest integer not less than the argument.

See also

floor

Prefix unary operator

cols

Returns the number of columns in a matrix.

See also

rows

Prefix unary operator

cos

Cosine.

Postfix unary operator

%

Example

100% /* = 10. */

Function

atan2

atan2(x, y) is the angle, in radians, between the positive x-axis and the point (x, y).

Prefix unary operator

acosh

Inverse hyperbolic cosine.

Prefix unary operator

asinh

Inverse hyperbolic sine.

Prefix unary operator

atanh

Inverse hyperbolic tangent.

Prefix unary operator

acos

Inverse cosine.

Prefix unary operator

asin

Inverse sine.

Prefix unary operator

atan

Inverse tangent.

Prefix unary operator

abs

Absolute value.

Prefix unary operator

arg

The argument (angular component) of a complex number.

Binary operator

and

Returns true if both arguments are true, false otherwise.

Binary operator

*

Multiplication.

Prefix unary operator

normf

The Frobenius norm of a matrix.

Prefix unary operator

num

Returns the numerator of a fraction.

See also

den

Prefix unary operator

not

Inverts a boolean value.

Binary operator

nCr

The binomial coefficient.

See also

nPr

Binary operator

nPr

Permutations. The first argument is the number of elements available for selection, and the second is the number of elements to be selected.

See also

nCr

Binary operator

or

Returns true if either one of the arguments are true.

Binary operator

+

Plus

This operator can be used to concatenate strings and arrays, and to append values to them.

Example

"here's" + ' johnny'; 'The value is ' + x; {1, 2} + {3, 4};

Left parenthesis

(

Function

lcm

Returns the least common multiple of a set of integers.

See also

gcd

Prefix unary operator

ln

The natural logarithm (the inverse of exp).

Function

lu

Creates an LU decomposition of a matrix. Accepts the matrix to be factorized, and optionally an augmentation matrix. Returns an array containing L, U, P, and the result of the augmentation if it was supplied.

Function

max

Returns the maximum of a set of values.

Function

min

Returns the minimum of a set of values.

Binary operator

mod

The remainder of integer division.

Right parenthesis

)

Binary operator

/

Division.

No-op

,

Prefix unary operator

identity

Creates an identity matrix.

Example

identity 2

Prefix unary operator

import

An alias for execute.

Prefix unary operator

ipart

The integer part of a real number.

See also

fpart

Binary operator

inc

Increment operator.

Example

x := 2; x inc 1; /* x is now 3. */

See also

dec

Prefix unary operator

im

Returns the imaginary part of a complex number.

See also

re

Function

if

Conditional execution of expressions.

Example

x := prompt 'Enter a number: '; if x < 10 then print 'less than 10.'; elif x > 100 then print 'greater than 100.'; else print 'between 10 and 100'; end;

See also

while, for, repeat

Value

i

The imaginary unit (square root of -1).

See also

complex

Binary operator

-

Subtraction.

Function

while

The while loop is a control flow statement which executes statements repeatedly as long as a given condition is true.

The following example prints the numbers from one to ten.

x := 1; while x <= 10 do print x; x inc 1; end;

See also

for, repeat, if

Prefix unary operator

wait

Waits for a given number of milliseconds.

No-op

until

See also

repeat

Value

true

A real value containing 1.

See also

false

Prefix unary operator

tanh

Hyperbolic tangent.

No-op

then

See also

if

Prefix unary operator

tan

Tangent.

Function

try

Tries to evaluate an expression. Returns an array containing two elements. If the evaluation succeeded, the first element will contain true and the second the result of the evaluation. If it failed, the first element will contain false and the second an error message.

Example

try( execute 'something'; );

Function

solve

Solves a system of linear equations. Accepts two matrices, the coefficients and the augmentation. Results in a matrix containing the vectors of the parametric solution.

Prefix unary operator

sqrt

Square root.

Prefix unary operator

sinh

Hyperbolic sine.

Function

sort

Sorts a given set of values. The values may be supplied as individual arguments, or as an array.

Prefix unary operator

size

Example

size [1, 2]; size 'abc'; size {1, 2, 3, 4};

Prefix unary operator

sin

Sine.

Function

rechelon

Reduced echelon.

See also

echelon

Postfix unary operator

radians

Converts a number from radians to degrees.

Example

print pi radians;

See also

degrees

Function

return

Returns from a function or an expression with a value.

Example

if x = 2 then return(3) end; 23;

Function

repeat

Executes statements repeatedly until a condition is true. This control flow statement differs from the while loop in that the first iteration is unconditional.

The following example prints the numbers from one to ten.

x := 1; repeat print x; x inc 1; until x > 10 end;

See also

for, while, if

Function

round

Rounds a number to a specified number of decimals.

Example

round(pi, 2) /* 3.14 */

Prefix unary operator

raise

Raises an error.

Example

if x <> 2 then raise 'x is supposed to be 2:('; end;

Prefix unary operator

rows

Returns the number of rows in a matrix.

See also

cols

Value

rand

A random number in the range [0, 1).

Prefix unary operator

re

Returns the real part of a complex number.

See also

im

Function

qr

Creates a QR decomposition of a matrix. Returns an array containing Q and R.

Prefix unary operator

prompt

Waits for the user to enter an expression in the console. Returns the result of the expression.

Prefix unary operator

print

Outputs a value to the console.

Value

pi

The real constant pi (= 3.141592...).

Binary operator

;

All this operator does is returning its right argument. Since it has a very low priority it may be used to separate multiple expressions.

Binary operator

:=

Assignment operator. Stores the right argument into the left argument.

No-op

}

See also

{

Function

{

Creates an array.

Example

{1, pi, i}

Binary operator

>=

Returns true if the left argument is greater than or equal to the right.

Binary operator

>

Returns true if the left argument is greater than the right.

Binary operator

=

Returns true if the left argument equals the right.

Binary operator

xor

Exclusive or. Returns true if exactly one of the arguments is true.

Binary operator

<>

Returns true if the left argument is unequal to the right.

Binary operator

<=

Returns true if the left argument is less than or equal to the right.

Binary operator

<

Returns true if the left argument is less than the right.

Data type

real

This data type represents "ordinary" numbers.

Real numbers with a zero fraction part are used to represent integers.

Real numbers are also used as booleans. A boolean is a value that is logically true or false; zero is considered false and everything else true.

Data type

complex

This data type represents complex numbers.

See also

re, im, i

Data type

string

This data type is used to represent text. Strings are delimited by either single or double quotes. Strings may be concatenated with the + operator.

Example

The following statement displays a string in the console:

print 'This is your wake up call!';

Data type

array

An array is a collection of values. Each value is identified by an integer index, which is specified when accessing the value. The first value in an array has index 1.

Example

The following example creates an array containing pi, i and a string:

{pi, i, "abc"}

See also

{, @, get

Data type

matrix

A matrix is a two dimensional array of numbers. An element in a matrix is referenced by specifying the row and column indices, respectively.

Example

mx := [[1, 2], [3, 4]]; print mx(2, 1); /* prints 2 */

See also

[, rows, cols

Data type

fraction

Example

fr := frac(3.5); fr2 := frac(7, 2); print fr = fr2; /* prints 1 */ print num fr; /* prints 7 */ print den fr; /* prints 2 */

See also

frac, num, den