From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: uzibalqa Newsgroups: gmane.emacs.help Subject: Re: Copying a string Date: Sun, 30 Jul 2023 21:31:50 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32344"; mail-complaints-to="usenet@ciao.gmane.io" Cc: uzibalqa via Users list for the GNU Emacs text editor To: uzibalqa Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 30 23:32:36 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qQE1j-0008BN-Tg for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 30 Jul 2023 23:32:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQE1B-0004fV-RS; Sun, 30 Jul 2023 17:32:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQE1A-0004fL-L7 for help-gnu-emacs@gnu.org; Sun, 30 Jul 2023 17:32:00 -0400 Original-Received: from mail-40138.protonmail.ch ([185.70.40.138]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQE17-0007lS-4p for help-gnu-emacs@gnu.org; Sun, 30 Jul 2023 17:32:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=vl44d6aqijdy7cf3p4co537ggm.protonmail; t=1690752713; x=1691011913; bh=fHURzLhtmbc6pWwyC3HN7TCWR4TKWOTCcF6/zn9GVCA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=KR91L9JiGbpu9ld91PuXGKL6Y2F9Sv2WjhYtP9uZiZrmT3xM73ewhYnszr6M+AAHI lu1JMTSMp9ZcVPEoB/UrMfTFucf1r/Kpi7u0f6jQS02Q5HpcoySfVDOQcMn/aGb6YJ 3MnBvW/I+pWjlS2DWstbec2vkapkGrtiJe2XPjZLFY3Td1rIkVNmQt1/vtyR0yxks+ vyspqhvpsdlBpC1qdzNYYQOdxdTJu7chMzr+JieFVMTPQLsFes5aFXplHSv3DEamRo tDZOL6LE59/uED5HWmQg+SyhNwRWvP8JBJnnkEwIhK0pOAT05I/cjFhuIAODem6o6B NBJohj05o+lHQ== In-Reply-To: Feedback-ID: 52887082:user:proton Received-SPF: pass client-ip=185.70.40.138; envelope-from=uzibalqa@proton.me; helo=mail-40138.protonmail.ch X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, TO_EQ_FM_DIRECT_MX=2.049, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:144504 Archived-At: Sent with Proton Mail secure email. ------- Original Message ------- On Monday, July 31st, 2023 at 9:07 AM, uzibalqa wrote: > I see many ways to copy a string >=20 > (mutant (substring string)) > (mutant (copy-sequence string)) >=20 > 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 ?=20 (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))