copy-string

Name

copy-string -- Return a string duplicated a specified number of times

Synopsis

(copy-string string num)

Description

Copies string num times and returns the result.

Example

(copy-string "x" 3) returns "xxx"

Author

Norman Walsh, <ndw@nwalsh.com>

Source Code

(define (copy-string string num)
  ;; Return a string duplicated a specified number of times
  (if (<= num 0)
      ""
      (let loop ((str string) (count (- num 1)))
	(if (<= count 0)
	    str
	    (loop (string-append str string) (- count 1))))))