Repeat a string: Difference between revisions

→‎{{header|Common Lisp}}: repeated concatenation is likely O(n^2); replaced with string-stream
No edit summary
(→‎{{header|Common Lisp}}: repeated concatenation is likely O(n^2); replaced with string-stream)
Line 58:
 
=={{header|Common Lisp}}==
<lang lisp>(defun repeat-string (n string)
(defun repeat (with-output-to-string (n stringstream)
(loop repeat n do (write-string string stream))))
(if (zerop n)
 
""
(concatenate 'string stringprinc (repeat-string (1-5 n) string))"hi"))</lang>
(princ (repeat-string 5 "hi"))
</lang>
 
=={{header|E}}==