# Exercise: List Operations
#
# Lists are created using string.split:
#   "a b c" " " string.split    # List of 3 strings
#
# List operations:
#   list.length   - Get number of elements
#   list.empty?   - Check if empty (returns 0 or 1)
#
# Access elements using variant.field-at:
#   "a b c" " " string.split 0 variant.field-at   # "a" (first)
#   "a b c" " " string.split 1 variant.field-at   # "b" (second)
#
# Your task: Work with list operations
# When done, delete the marker line below.

# I AM NOT DONE

: test-list-length ( -- )
    # Get the length of a 4-element list
    "one two three four" " " string.split list.length
    # Do not edit below this line
    4 test.assert-eq
;

: test-list-first ( -- )
    # Get the first element (index 0) of "alpha beta gamma"
    # Your code here - split the string into a list and pick the
    # element at index 0.
    ""
    # Do not edit below this line
    "alpha" string.equal? test.assert
;

: test-list-last ( -- )
    # Get the last element (index 2) of "alpha beta gamma"
    # Your code here
    ""
    # Do not edit below this line
    "gamma" string.equal? test.assert
;

: test-list-empty ( -- )
    # An empty string split gives a list with one empty string element
    # To check list operations, use a single element list
    "single" " " string.split list.empty?
    # Do not edit below this line
    not test.assert
;
