DEV Community

loading...

Discussion on: Daily Challenge #40 - Counting Sheep

Collapse
alvaromontoro profile image
Alvaro Montoro

Scheme

(define (countSheep n)
  (if (< n 1) 
    ""
    (string-append (countSheep (- n 1)) (number->string n) " sheep...")
  )
)

A demo can be seen in Repl.it. The function would be called (countSheep 4) and the result would be:

"1 sheep...2 sheep...3 sheep...4 sheep..."