Chapter 5. Conceptos de GEL

Table of Contents

Valores
Números
Booleanos
Cadenas
Nulo
Usar variables
Configurar variables
Variables integradas
Resultado de la variable anterior
Usar funciones
Definir funciones
Listas de argumentos de variables
Pasar funciones a funciones
Operaciones con funciones
Separador
Comentarios
Evaluación modular
Lista de operadores GEL

GEL significa Lenguaje de Extensión de Genius. Éste es el lenguaje que se utiliza para escribir programas para Genius. Un programa en GEL es simplemente una expresión que se evalúa como un número, una matriz, o cualquier objeto en GEL. Por lo tanto, la Herramienta matemática Genius se puede utilizar como una simple calculadora o como una herramienta de investigación teórica muy potente. La sintaxis está pensada para suavizar lo más posible la curva de aprendizaje, especialmente para usarlo como calculadora.

Valores

Los valores en GEL pueden ser números, booleanos o cadenas. GEL también trata las matrices como valores. Los valores se pueden usar en cálculos, asignarse a variables y devolverse desde funciones, entre otros usos.

Números

Integers are the first type of number in GEL. Integers are written in the normal way.

1234

Hexadecimal and octal numbers can be written using C notation. For example:

0x123ABC
01234

Or you can type numbers in an arbitrary base using <base>\<number>. Digits higher than 10 use letters in a similar way to hexadecimal. For example, a number in base 23 could be written:

23\1234ABCD

The second type of GEL number is rationals. Rationals are simply achieved by dividing two integers. So one could write:

3/4

to get three quarters. Rationals also accept mixed fraction notation. So in order to get one and three tenths you could write:

1 3/10

The next type of number is floating point. These are entered in a similar fashion to C notation. You can use E, e or @ as the exponent delimiter. Note that using the exponent delimiter gives a float even if there is no decimal point in the number. Examples:

1.315
7.887e77
7.887e-77
.3
0.3
77e5

When Genius prints a floating point number it will always append a .0 even if the number is whole. This is to indicate that floating point numbers are taken as imprecise quantities. When a number is written in the scientific notation, it is always a floating point number and thus Genius does not print the .0.

The final type of number in GEL is the complex numbers. You can enter a complex number as a sum of real and imaginary parts. To add an imaginary part, append an i. Here are examples of entering complex numbers:

1+2i
8.01i
77*e^(1.3i)

Important

Al introducir números imaginarios, deba haber un número delante de la i. Si usa i por sí sola, Genius lo interpretará como una referencia a la variable i. Si necesita referirse a i por sí sola, use 1i en su lugar.

Para usar notación de fracciones mixtas con números imaginarios debe colocar las fracciones mixtas entre paréntesis (ej. (1 2/5)i).

Booleanos

Genius también soporta valores booleanos nativos. Las dos constantes booleanas están definidas como true y false; estos identificadores se pueden utilizar como cualquier otra variable. Así mismo, puede utilizar los identificadores True, TRUE, False y FALSE como alias de las anteriores.

Puede usar un valor booleano o cualquier expresión que produzca un número o valor booleano en cualquier lugar donde se espera una expresión Booleana. Si Genius necesita evaluar un valor numérico como un valor booleano interpretará «0» como false y cualquier otro valor como true.

In addition, you can do arithmetic with Boolean values. For example:

( (1 + true) - false ) * true

is the same as:

( (true or true) or not false ) and true

Only addition, subtraction and multiplication are supported. If you mix numbers with Booleans in an expression then the numbers are converted to Booleans as described above. This means that, for example:

1 == true

always evaluates to true since 1 will be converted to true before being compared to true.

Cadenas

Like numbers and Booleans, strings in GEL can be stored as values inside variables and passed to functions. You can also concatenate a string with another value using the plus operator. For example:

a=2+3;"The result is: "+a

will create the string:

The result is: 5

You can also use C-like escape sequences such as \n,\t,\b,\a and \r. To get a \ or " into the string you can quote it with a \. For example:

"Slash: \\ Quotes: \" Tabs: \t1\t2\t3"

will make a string:

Slash: \ Quotes: " Tabs: 	1	2	3

Do note however that when a string is returned from a function, escapes are quoted, so that the output can be used as input. If you wish to print the string as it is (without escapes), use the print or printn functions.

In addition, you can use the library function string to convert anything to a string. For example:

string(22)

will return

"22"

Strings can also be compared with == (equal), != (not equal) and <=> (comparison) operators

Nulo

Existe un valor especial llamado null. No se permite efectuar operaciones sobre él y no se muestra nada cuando se devuelve este valor. Por lo tanto, null es útil cuando no quiera ninguna salida de una expresión. El valor null puede obtenerse como una expresión al escribir ., la constante null o nada. Nada referido a que si termina una expresión con un separador ;, equivale a terminar la expresión con un separador seguido de null.

Example:

x=5;.
x=5;

Algunas funciones devuelven null cuando no pueden devolver un valor o producen algún error. También se usa null como un vector o matriz vacía o una referencia vacía.