# Exercise: list.map - Transform Each Element
#
# `list.map` applies a quotation to every element, building a new list.
#
# Stack effect: ( Variant Quotation -- Variant )
#
# Example:
#   "apple banana" " " string.split [ string.to-upper ] list.map
#   # Result: list of "APPLE" "BANANA"
#
# HIGHER-ORDER PATTERN:
# map is one of the fundamental higher-order operations.
# You provide WHAT to do to each element (the quotation).
# map handles HOW to iterate and collect results.
#
# Your task: Transform each word to uppercase.
# When done, delete the marker line below.

# I AM NOT DONE

: upcase-all ( Variant -- Variant )
    # Your code here - transform each element to uppercase.
    drop "x" " " string.split
;

: test-map ( -- )
    "hello world" " " string.split upcase-all
    # Do not edit below this line
    dup list.length 2 test.assert-eq
    dup 0 variant.field-at "HELLO" string.equal? test.assert
    1 variant.field-at "WORLD" string.equal? test.assert
;
