Repository navigation
Syntax
SP is a simple programming language designed for educational purposes. It supports basic programming constructs such as variables, arithmetic operations, functions, conditionals, loops, and more.
Variables are declared and assigned using the = operator.
x = 10;
y = "Hello, World!";SP supports basic arithmetic operations: addition (+), subtraction (-), multiplication (*), and division (/).
a = 5 + 3;
b = 10 - 2;
c = 4 * 2;
d = 8 / 2;Functions are defined using the funcion keyword and can return values using the retorna keyword.
funcion suma(a, b) {
retorna a + b;
}
resultado = suma(3, 4); // resultado is 7Conditional statements are written using si for if and alreves for else.
x = 10;
si (x > 5) {
imprimir("x is greater than 5");
} alreves {
imprimir("x is not greater than 5");
}SP supports mientras (while) and para (for) loops.
i = 0;
mientras (i < 5) {
imprimir(i);
i = i + 1;
}para (i = 0; i < 5; i = i + 1) {
imprimir(i);
}Use the imprimir function to print values to the console.
imprimir("Hello, World!");Use the importar keyword to import and run another SP file.
importar("other_file.sp");Use the entrada function to get user input.
nombre = entrada("¿Cuál es tu nombre?");
imprimir("Hola, " + nombre);Here is a complete example of an SP program:
funcion factorial(n) {
si (n == 0) {
retorna 1;
} alreves {
retorna n * factorial(n - 1);
}
}
numero = 5;
resultado = factorial(numero);
imprimir("El factorial de " + numero + " es " + resultado);This program defines a function to calculate the factorial of a number and prints the result.
This project is licensed under the MIT License.