string-helpers.scm 562 B

1234567891011121314151617181920212223
  1. (define-module (string-helpers)
  2. #:use-module (rnrs base)
  3. #:use-module ((guile) #:select (lambda* λ
  4. when
  5. call-with-output-string))
  6. #:use-module (ice-9 textual-ports)
  7. #:export (char->string
  8. string-repeat))
  9. (define char->string
  10. (λ (char)
  11. (list->string (list char))))
  12. (define (string-repeat str n)
  13. (call-with-output-string
  14. (λ (port)
  15. (let iter ([count° n])
  16. (when (> count° 0)
  17. (put-string port str)
  18. (iter (- count° 1)))))))