; hey, Scheme also has a way to ; get the string version of a number! ; built-in: ; number->string: number -> string ; purpose: it expects a number, and ; returns a string version of that ; number (number->string 34) ; when a function CAREFULLY calls itself, ; that is called a recursive function; ; (make sure it has at least one BRANCH ; that does NOT call itself, ; and make sure the branch(es) that DO ; call itself do so on a "smaller" ; version of the problem) ; I would like a function that builds a ; string that "counts down" from a ; positive integer to 0 and then ; blasts off; ; countdown: number -> string ; purpose: expects a positive integer ; and returns a string "counting down" ; from that integer to 0 and then ; including a blastoff message (EXAMPLE (countdown 5) "5 4 3 2 1 0 BLASTOFF!") (EXAMPLE (countdown 0) "0 BLASTOFF!") (EXAMPLE (countdown -3) "NOT VALID INPUT!") (define (countdown pos-int) (cond [(< pos-int 0) "NOT VALID INPUT!"] [(= pos-int 0) "0 BLASTOFF!"] [else (string-append (number->string pos-int) " " (countdown (- pos-int 1)))] ) ) (countdown 5) (countdown 0) (countdown -3) (countdown 100)