Programming language reference · Égua

Égua

This reference introduces the Égua programming language and its Portuguese syntax, including data, control flow, functions, collections, object-oriented features, and standard libraries.

Category Programming languageReference Égua

01 · Overview

About Égua

Égua is an interpreted programming language with Portuguese keywords and messages. Its official site presents it as an accessible way to practice programming concepts without relying on English vocabulary; its implementation combines imperative and functional features with object-oriented programming.

This page organizes syntax and features described in the official documentation. It is a reference guide, not a replacement for the complete language documentation.

02 · Organization

Source files and code

A program consists of statements and blocks enclosed in braces. The project documentation uses .egua source files, // line comments, and semicolons to end statements. Execution can begin with statements directly in the file; functions and classes are declared where needed.

// First program
var nome = "Ana";
escreva("Hello, " + nome);

Key reserved words include var, se, senão, para, função, retorna, and classe. Their Portuguese spelling is part of the syntax.

03 · Data

Variables and scope

var declares a variable, with or without an initial value. Later assignment uses =. Variables can have global scope or local scope inside a brace-delimited block; an outer variable is visible inside nested blocks, but a local variable is unavailable outside its defining block.

var pontos = 0;
pontos = pontos + 1;

se (pontos > 0) {
  var mensagem = "There are points";
  escreva(mensagem);
}

Égua determines a value's type at runtime; a type is not written next to a variable name. Use descriptive names and keep each variable in the narrowest scope that suits the algorithm.

04 · Values

Types and collections

Values include whole or decimal numbers, text in single or double quotes, logical values verdadeiro and falso, and the missing value nulo. Lists are ordered and use square brackets; dictionaries associate keys with values and use braces.

FormExampleNote
Number12, 3.5Integer or floating-point value.
Text"Hello", 'a'A quoted sequence.
Logicalverdadeiro, falsoUsed in conditions.
List[4, "five"]Zero-based index; variable length.
Dictionary{'nome': 'Ana'}Access by key.
var notas = [8, 6.5, 9];
var cadastro = {"nome": "Ana"};
escreva(notas[0]);
escreva(cadastro["nome"]);

Lists and text are indexed from zero. The documentation also describes negative indices for text, counted from the end; reading a missing list index raises an error, while assigning beyond the end can extend the list and fill skipped positions with nulo.

05 · Expressions

Operators and comparisons

GroupOperatorsUse
Arithmetic** * / + - %Power, calculations, and remainder.
Comparison> >= < <= == !=Compare values; equality requires matching type and value.
Logicale ouConjunction and disjunction.
MembershipemChecks a list value, text character, or dictionary key.
Bitwise<< >> & ^ |Shifts and operations on bits.
var resultado = 2 ** 3 + 1;
var aprovado = resultado >= 8 e resultado < 10;
var tem_nota = 8 em [6, 8, 9];
escreva(aprovado);

Operator precedence sets evaluation order. Use parentheses when an expression combines several groups.

06 · Flow

Conditions and loops

se, senão se, and senão select a block. Loop forms include enquanto and para; para resembles a loop with initialization, test, and update steps. Conditions use logical values.

var notas = [8, 5.5, 9];
para (var i = 0; i < tamanho(notas); i = i + 1) {
  se (notas[i] >= 7) {
    escreva("Passed");
  } senão se (notas[i] >= 5) {
    escreva("Review period");
  } senão {
    escreva("Not passed");
  }
}

var contador = 0;
enquanto (contador < 2) {
  escreva(contador);
  contador = contador + 1;
}

verdadeiro and values other than falso and nulo evaluate as true under the truthiness rules in the documentation.

07 · Reuse

Functions

A named function uses função, comma-separated parameters in parentheses, and a brace-delimited body. retorna sends a value to the call site. Anonymous functions can be stored or passed to other functions, for example to transform list elements.

função classificar(nota) {
  se (nota >= 7) {
    retorna("Passed");
  } senão {
    retorna("Keep studying");
  }
}

var resultado = classificar(8);
escreva(resultado);

Functions can return lists, text, numbers, or other values. Built-ins mapear, filtrar, and para_cada accept functions as arguments.

08 · Modeling

Classes and objects

classe declares a structure with methods. Calling the class name with parentheses creates an instance; methods are called on that instance with a dot. The special construtor method runs when an instance is created, and isto refers to the current instance. The documentation also covers inheritance with herda and access to a parent implementation with super.

classe Contador {
  construtor(valor) {
    isto.valor = valor;
  }
  avancar() {
    isto.valor = isto.valor + 1;
    retorna isto.valor;
  }
}

var contador = Contador(2);
escreva(contador.avancar());

Use classes to group related data and behavior; a simple function is often enough for a short transformation.

09 · Built-in features

Functions and libraries

escreva displays values. Documented built-ins include aleatório, aleatório_entre, inteiro, real, tamanho, para_cada, mapear, filtrar, and ordenar. See the official pages for the full list and each function's behavior.

Standard libraries are loaded explicitly with importar(...). Official documentation describes libraries for mathematics, text, time, and HTTP requests.

var tempo = importar("tempo");
escreva(tempo.agora());

var dobro = mapear([1, 2, 3], função(valor) {
  retorna valor * 2;
});
escreva(dobro);

10 · In practice

Complete example

This program classifies a list of results and shows how many reached the target score.

função aprovado(nota) {
  retorna nota >= 7;
}

var notas = [8, 5.5, 9, 6];
var aprovadas = filtrar(notas, função(nota) {
  retorna aprovado(nota);
});

escreva("Grades: ", notas);
escreva("Passed: ", aprovadas);
escreva("Count: ", tamanho(aprovadas));

11 · Sources

Official documentation

Back to the Potoo IDE manual

Browse the other references and project information.

Open the manual