# Exercise: Safe Argument Access
#
# `args.at` returns "" for out-of-bounds indices, but that conflates
# "missing" with "explicitly empty". When the distinction matters,
# bounds-check first with `args.count`.
#
# The idiom:
#
#   ( index default )
#   over args.count i.<                   ← is index < count?
#   [ swap args.at nip ]                   ← in bounds: keep arg
#   [ nip ]                                ← out of bounds: keep default
#   if
#
# Your task: Write `arg-or` — given an index and a default string,
# return the argument at that index if it exists, or the default if
# the index is out of bounds.
#
# This is the building block for proper CLI parsing.
#
# The test below only verifies your word runs. To see the real
# behaviour, including the precise distinction between "missing"
# and "explicitly empty":
#
#   #!/usr/bin/env seqc
#   : arg-or ( Int String -- String )
#       over args.count i.<
#       [ drop args.at ]
#       [ nip ]
#       if
#   ;
#   : main ( -- Int )
#       1 "(no name given)" arg-or io.write-line
#       0
#   ;
#
#   $ chmod +x try-or.seq
#   $ ./try-or.seq                 → (no name given)
#   $ ./try-or.seq alice           → alice
#   $ ./try-or.seq ""              → (a blank line — empty IS a valid arg)
#
# Notice the third case: an explicit empty string is in-bounds, so
# `arg-or` returns it verbatim. That's the precise distinction the
# previous exercise's `arg-empty?` couldn't make.
#
# When done, delete the marker line below.

# I AM NOT DONE

: arg-or ( Int String -- String )
    # Your code here
    nip
;

: test-runs ( -- )
    0 "fallback" arg-or drop
    # Do not edit below this line
    true test.assert
;
