Skip to content

Mini Programs ​

Looking for guided practice?

Use Practice and Mini projects. This page is a catalog of short scripts — not a tutorial series.

Short scripts. Not a tutorial series.

Inline examples below run from any working directory. Commands that use examples/... paths require a git clone of this repository, with the shell cwd at the repo root (examples/ is not installed by pip/pipx).

Countdown ​

echo
fn countdown(start: int) {
    for i: int in start..0 by -1 {
        say(i);
    }
}

countdown(3);
text
3
2
1
0

Frequency counter ​

echo
words: list = ["a", "b", "a"];
counts: hash = {};

i: int = 0;
while i < words.length() {
    word: str = words[i];
    counts[word] = counts.ensure(word, 0) + 1;
    i = i + 1;
}

say(counts);
text
{"a": 2, "b": 1}

JSON job report ​

examples/json_report.echo reads a JSON suite, prints a summary, and can write it back out.

bash
elang examples/json_report.echo -- examples/sample_jobs.json
ECHO_REPORT=report.json elang examples/json_report.echo -- examples/sample_jobs.json

Uses args(), envOr(), readFile(), writeFile(), parseJson(), and writeJson().

Bank account ​

Interactive class demo: examples/bank_account.echo (also in the playground).

bash
elang examples/bank_account.echo

Commands: deposit / withdraw / balance / exit (short: d w b q). Amounts use asFloatOr.

URL and Base64 ​

examples/url_and_base64.echo builds a query URL and round-trips Base64 (no network). Also in the playground.

bash
elang examples/url_and_base64.echo

Uses urlQuery / urlJoin, base64Encode / base64Decode, and httpOk / httpRedirect (status helpers only). Live httpGet needs the CLI host (allow_http=True); the playground denies it (E2801).

std/… imports ​

examples/std_imports.echo imports helpers from "std/meta", "std/url", "std/base64", and "std/http" (status helpers only). Also in the playground.

bash
elang examples/std_imports.echo

YAML and math ​

examples/yaml_and_math.echo round-trips YAML via "std/yaml", uses "std/math", and shows trace (playground-safe). Also in the playground.

bash
elang examples/yaml_and_math.echo

Nested modules (CLI) ​

examples/modules_demo/ shows nested + ./ imports beside std/meta:

bash
elang examples/modules_demo/app.echo
text
2+3 = 5
6^2 = 36
std ready: true

See Also ​

Echo is in active development. The docs reflect the current implementation.