// Test all new string and array primitives

fn main() {
    // str_split
    let parts = str_split("hello,world,scyla", ",")
    println(parts)

    // str_contains
    let has_world = str_contains("hello world", "world")
    println(has_world)

    // str_replace
    let replaced = str_replace("def hello():", "def", "fn")
    println(replaced)

    // str_trim
    let trimmed = str_trim("  hello  ")
    println(trimmed)

    // str_slice
    let sliced = str_slice("hello world", 0, 5)
    println(sliced)

    // str_char_at
    let ch = str_char_at("hello", 1)
    println(ch)

    // str_lower / str_upper
    println(str_lower("HELLO"))
    println(str_upper("hello"))

    // str_find
    let idx = str_find("hello world", "world")
    println(idx)
    let not_found = str_find("hello", "xyz")
    println(not_found)

    // str_ends_with
    println(str_ends_with("hello.py", ".py"))
    println(str_ends_with("hello.py", ".rs"))

    // str_len (existing)
    println(str_len("hello"))

    // starts_with (existing)
    println(starts_with("import numpy", "import"))

    // array_new, array_push, array_len, array_get
    let arr = array_new()
    let arr = array_push(arr, "first")
    let arr = array_push(arr, "second")
    let arr = array_push(arr, "third")
    println(arr)
    println(array_len(arr))
    println(array_get(arr, 1))

    // array_contains
    println(array_contains(arr, "second"))
    println(array_contains(arr, "fourth"))

    // array_slice
    let sub = array_slice(arr, 0, 2)
    println(sub)

    // str_join
    let joined = str_join(str_split("a,b,c", ","), " -> ")
    println(joined)

    // int_to_str
    let s = int_to_str(42)
    println(s)

    // str_lines
    let content = "line1\nline2\nline3"
    let lines = str_lines(content)
    println(lines)

    println("All string/array primitives working!")
}
