seqlings 3.0.7

Interactive exercises for learning Seq, a stack-based programming language
# Exercise: Simple Recursion - Countdown
#
# A recursive function calls itself with a smaller problem
# until it reaches a base case.
#
# Structure:
#   : recursive-word ( inputs -- outputs )
#       base-case-check if
#           base-case-action
#       else
#           do-something
#           smaller-problem recursive-word
#       then
#   ;
#
# Your task: Define `countdown` that counts from n down to 1.
# It should return the sum of all numbers counted.
# countdown(3) = 3 + 2 + 1 i.= 6
#
# Base case: n <= 0 returns 0
# Recursive case: n + countdown(n-1)
#
# When done, delete the marker line below.

# I AM NOT DONE

: countdown ( Int -- Int )
    # Your code here
    drop 0
;

: test-countdown ( -- )
    5 countdown
    # Do not edit below this line
    15 test.assert-eq   # 5+4+3+2+1 i.= 15
;