Executable learning material

Small programs, real output.

The sources below come directly from the repository's examples directory. Expected output was verified against the current compiler and runtime.

01 · First program

Print a line of text with the language's runtime output function.

First program .kwe
bipụta("Ndewo Ụwa!")
Output: Ndewo Ụwa!

02 · Functions

Declare a function, return a value, and call it from the top level.

Functions .kwe
ọrụ gbakọọ(a, b) {
    laghachi a + b
}

nsonaazụ = gbakọọ(10, 20)
bipụta(nsonaazụ)
Output: 30

03 · Conditions

Use a strict Boolean condition and a flow-aware branch variable.

Conditions .kwe
afọ = 36
ọ bụrụ (afọ >= 18) {
    ọkwa = "Okenye"
} ọzọ {
    ọkwa = "Nwatakịrị"
}
bipụta(ọkwa)
Output: Okenye

04 · Collections

Work with a homogeneous array and a typed object.

Collections .kwe
ahaNdị = ["Uche", "Ada", "Obi"]
mmadụ = { aha: ahaNdị[0], afọ: 36 }
bipụta(ahaNdị)
bipụta(mmadụ)
bipụta(mmadụ.aha)
Output: ["Uche","Ada","Obi"] {"aha":"Uche","afọ":36} Uche

05 · Modules

Import named values from a relative Kwechiri module.

Modules .kwe
webata { gbakọọ, pi } site na "./mgbakọ.kwe"

bipụta(gbakọọ(pi, 2))
Output: 5.14159