string.scm 456 B

12345678910111213141516171819
  1. (define-module (utils string))
  2. (define-public (stringify sth)
  3. (cond
  4. [(number? sth) (number->string sth)]
  5. [(string? sth) sth]
  6. [else (simple-format #f "~s" sth)]))
  7. (define-public n-times-string
  8. (lambda* (string-to-repeat times)
  9. (let loop ([remaining-times times] [result ""])
  10. (cond
  11. [(zero? remaining-times) result]
  12. [else
  13. (loop (- remaining-times 1)
  14. (string-append result string-to-repeat))]))))