Jump to content

Repeat a string: Difference between revisions

Line 362:
do (setf (subseq result i (+ i len)) string))
result)</lang>
 
For those who love conciseness and efficiency, even at the cost of readability:
<lang lisp>(defun repeat-string (n string)
(format nil "~V@{~a~:*~}" n string))</lang>
 
 
<lang lisp>(princ (repeat-string 5 "hi"))</lang>
 
 
A single character may be repeated using just the builtin <code>make-string</code>:
47

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.