// array and string slicing: arr[1..3], arr[1:], str[0..5]

fn main() {
    // --- array slicing ---
    let nums = [10, 20, 30, 40, 50]
    
    // basic slice: arr[start..end]
    let mid = nums[1..3]
    println(mid)          // [20, 30]
    
    // slice from start
    let first_two = nums[0..2]
    println(first_two)    // [10, 20]
    
    // slice to end (open-ended)
    let tail = nums[2..]
    println(tail)         // [30, 40, 50]
    
    // single element slice
    let single = nums[3..4]
    println(single)       // [40]
    
    // --- string slicing ---
    let greeting = "hello, world!"
    
    // basic substring
    let hello = greeting[0..5]
    println(hello)        // "hello"
    
    // slice from index
    let world = greeting[7..]
    println(world)        // "world!"
    
    // slice to index
    let hello_comma = greeting[0..6]
    println(hello_comma)  // "hello,"
    
    // --- slicing in expressions ---
    let data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    let first = data[0..3]
    let last = data[7..]
    println(first)
    println(last)
}
