Soplang Logo
Soplang

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

FunctionMeaningEnglish EquivalentExample
qor()Print to consoleprint()

qor("Salaan, Adduunka!")

gelin()Read user inputinput()

door magac = gelin("Magacaaga geli: ")

nooc()Get type of a valuetypeofqor(nooc(magac))
abn()Convert to integerint()door n = abn("5")
jajab()Convert to floatfloat()

door f = jajab("3.14")

qoraal()Convert to stringstr()door s = qoraal(25)
bool()Convert to booleanbool()door b = bool(1)
teed()Create an arraylist()

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 as walax("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 from 1 through 6, use daji(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], and baaxad(1, 10, 2) produces [1, 3, 5, 7, 9].
  • daji() / kor() return abn values.

Examples

builtins_examples.sop

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

FunctionDescriptionExample
duub(x)Round to the nearest integer, with ties away from zeroduub(-2.5) returns -3
sugan(x)Return the absolute valuesugan(-5) returns 5
yar(...)Return the smallest numeric argumentyar(4, 2, 8) returns 2
weyn(...)Return the largest numeric argumentweyn(4, 2, 8) returns 8
jibbaar(a, b)Raise a number to a powerjibbaar(2, 3) returns 8
xidid(x)Return the square rootxidid(9) returns 3
numeric_helpers.sop
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.

On this page