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: Emanuel Berg
Subject: Re: String variable composed of a repeat character
Date: Sun, 09 May 2021 00:06:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Tassilo Horn wrote:

>> 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):
>
> (defun foo/repeat-string (n str)
>   (with-temp-buffer
>     (dotimes (_ n)
>       (insert str))
>     (buffer-string)))

Pretty, but there is an easier way and you know it :)

  (make-string 3 ?w) ; www

But what don't you do to get char/string transparency...

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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