# Exercise: Combining File Operations
#
# Now we put the previous four words together to build a small file
# from scratch and read it back.
#
# Words you'll use:
#
#   file.spit    ( content path -- status )   overwrite a file
#   file.append  ( content path -- status )   add to the end of a file
#   file.slurp   ( path -- content status )   read it all back
#
# `file.append` has the same argument order as `file.spit`. The
# difference is that `spit` truncates first; `append` does not. A
# common pattern is to start a file with one `spit ""` (or
# `spit <header>`) and then loop, calling `append` per record.
#
# Your task: Build /tmp/seqlings-05-log.txt as if it were an event
# log, then read the result and return it. The expected content is:
#
#   start
#   step 1
#   step 2
#   done
#
# Build it like this:
#
#   1. spit "start\n" to truncate-and-create the file.
#   2. append "step 1\n", then "step 2\n", in two separate calls.
#   3. append "done\n".
#   4. slurp the file, chomp the trailing newline, return.
#
# When done, delete the marker line below.

# I AM NOT DONE

: build-log ( -- String )
    # Implement the four-step recipe above.
    ""
;

: test-combine ( -- )
    build-log
    # Do not edit below this line
    "start\nstep 1\nstep 2\ndone" string.equal? test.assert
;
