help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String variable composed of a repeat character


From: Tassilo Horn
Subject: Re: String variable composed of a repeat character
Date: Sat, 08 May 2021 16:20:45 +0200
User-agent: mu4e 1.5.13; emacs 28.0.50

pauline-galea@gmx.com writes:

> How can a construct a string variable composed of repeating a
> character n times?

One way to do it (which works for both repeating a character or a
string):

--8<---------------cut here---------------start------------->8---
(defun foo/repeat-string (n str)
  (with-temp-buffer
    (dotimes (_ n)
      (insert str))
    (buffer-string)))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]