Built-in Functions in Soplang
Reference for Soplang built-ins: console input and output, type conversion, collection creation, ranges, randomness, and numeric helpers.
Built-in Functions in Soplang
Built-in functions are available without imports. They cover printing, user
input, type inspection and conversion, collection creation, numeric operations,
and ranges. Soplang 3.6 also provides khalad, xirmo, urur,
sug, channels, file and network functions, and bundled modules. See the
3.6 overview and full reference
for their arguments and behavior.
Core Built-in Function Reference
| Function | Meaning | English Equivalent | Example |
|---|---|---|---|
| qor() | Print to console | print() | qor("Salaan, Adduunka!") |
| gelin() | Read user input | input() | door magac = gelin("Magacaaga geli: ") |
| nooc() | Get type of a value | typeof | qor(nooc(magac)) |
| abn() | Convert to integer | int() | door n = abn("5") |
| jajab() | Convert to float | float() | door f = jajab("3.14") |
| qoraal() | Convert to string | str() | door s = qoraal(25) |
| bool() | Convert to boolean | bool() | door b = bool(1) |
| teed() | Create an array | list() | door liis = teed(1, 2, 3) |
| walax() | Create an object | object() | door obj = walax("magac", "Ali") |
| daji() | Round down | Math.floor() | door x = daji(4.9) |
| kor() | Round up | Math.ceil() | door x = kor(4.2) |
| dherer() | Length of string, list, or object | len()/.length | door l = dherer("text") |
| xul() | Random number or random list item | random() | door n = xul(1, 6) |
| baaxad() | Create a list of numbers (range) | range() | door l = baaxad(1, 5) |
Notes
walax()accepts alternating key-value arguments, such aswalax("magac", "Ali", "da", 20). An object literal is often simpler:{magac: "Ali", da: 20}.dherer()works on strings, lists, and objects. All three also support a.dherer()method.xul()supports three forms:xul()returns a random floating-point number in[0, 1).xul(a, b)returns a random floating-point number in[a, b). For an integer from1through6, usedaji(xul(1, 7)).xul(list)returns one randomly chosen list item.
baaxad()creates a list of integers, excluding the stop bound:baaxad(5)produces[0, 1, 2, 3, 4],baaxad(2, 6)produces[2, 3, 4, 5], andbaaxad(1, 10, 2)produces[1, 3, 5, 7, 9].daji()/kor()returnabnvalues.
Examples
builtins_examples.sop
// Output qor("Hello World") // Input door magac = gelin("Magacaaga geli: ") qor("Magacaaga waa: " + magac) // Type detection door t = nooc(5) qor("Type: " + t) // Conversion door a = abn("42") door f = jajab("3.14") door s = qoraal(100) door b = bool(0) // List and Object creation door l = teed(1, 2, 3) door o = walax("name", "Ayaan", "age", 20) // Math rounding qor("Floor: " + daji(4.8)) qor("Ceil: " + kor(4.2)) // Random number door r = daji(xul(1, 7)) qor("Random: " + r) // Random item and range qor(xul(["Cas", "Buluug", "Cagaar"])) qor(baaxad(1, 5)) // [1, 2, 3, 4]
Numeric Helpers in Soplang 3
| Function | Description | Example |
|---|---|---|
duub(x) | Round to the nearest integer, with ties away from zero | duub(-2.5) returns -3 |
sugan(x) | Return the absolute value | sugan(-5) returns 5 |
yar(...) | Return the smallest numeric argument | yar(4, 2, 8) returns 2 |
weyn(...) | Return the largest numeric argument | weyn(4, 2, 8) returns 8 |
jibbaar(a, b) | Raise a number to a power | jibbaar(2, 3) returns 8 |
xidid(x) | Return the square root | xidid(9) returns 3 |
qor(duub(-2.5)) // -3 qor(sugan(-5)) // 5 qor(yar(4, 2, 8)) // 2 qor(weyn(4, 2, 8)) // 8 qor(jibbaar(2, 3)) // 8 qor(xidid(9)) // 3
xul() and xul(a, b) exclude the upper bound. Passing an empty list to
xul(list) produces an error. baaxad() accepts integers only and rejects
a zero step. Each function validates its argument count.
General file I/O, HTTP, and network functions remain planned work.