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

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

Re: Copying a string


From: uzibalqa
Subject: Re: Copying a string
Date: Sun, 30 Jul 2023 21:31:50 +0000





Sent with Proton Mail secure email.

------- Original Message -------
On Monday, July 31st, 2023 at 9:07 AM, uzibalqa <uzibalqa@proton.me> wrote:


> I see many ways to copy a string
> 
> (mutant (substring string))
> (mutant (copy-sequence string))
> 
> Any others ways ? And what should one use routinely ?

I am swapping characters, I can use as I am doing '(mutant string)'
or as before I had (mutant (copy-sequence string))

I do not think it makes a difference, and that using (copy-sequence string)
would be overkill. Right ? 

(defun swap-chars (string p q)
  "Swap characters at INDEX1 and INDEX2 in STRING."

  (let* ( (char1 (elt string p))
          (char2 (elt string q))
          (mutant string))

    (aset mutant p char2)
    (aset mutant q char1)

    mutant))




reply via email to

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