From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Andreas_R=c3=b6hler?= Newsgroups: gmane.emacs.help Subject: Re: Replace element in list Date: Mon, 2 Sep 2019 16:00:30 +0200 Message-ID: References: <6a632b18-bbd6-7096-229d-6c890b6bdb6f@easy-emacs.de> <20190902134342.GG1466@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="25517"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 02 16:01:19 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i4mtS-0006VU-6v for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Sep 2019 16:01:18 +0200 Original-Received: from localhost ([::1]:36896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4mtQ-0002rb-Vt for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Sep 2019 10:01:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55740) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4mss-0002m0-1u for help-gnu-emacs@gnu.org; Mon, 02 Sep 2019 10:00:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i4msm-0006EW-3w for help-gnu-emacs@gnu.org; Mon, 02 Sep 2019 10:00:41 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.187]:39703) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i4msl-0006Au-Po for help-gnu-emacs@gnu.org; Mon, 02 Sep 2019 10:00:36 -0400 Original-Received: from [192.168.178.31] ([88.130.49.12]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N7iT4-1iIjBV3vbm-014iuA for ; Mon, 02 Sep 2019 16:00:32 +0200 In-Reply-To: <20190902134342.GG1466@tuxteam.de> Content-Language: en-US X-Provags-ID: V03:K1:LO0yl6VbCNqsS77A57z53CyESWskcJtoSo+8V99sOhEa0ERT2vw qGmx94cCbhLC/viFzplAn4IDCz2BrJlSBLjisWyCKP4KMVJOYLxLYHu0xVw8cuaKUCCkC7r 7BgqKAjET3yM52WsfTr03920AhlHPI/s639lVRIAMOVxO7OCgYQwxe2iOSX9+nt6jLQ4tcp LwHO89u7+rBjcZG65Hv/Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:sBaIf1qmsbU=:/aK10dDKSHJr1tcfn9s4Tc 7QE6/ehkJq/honQFMsQlQEdbmT9b5nAeAABht/9S+eI3t2aa/TGxKiikwwlaKaMcdjYYeAM2y 8nDBpH1ffvI4Uf5cD1Ws5SaDXwBpekttwBNvB0nT8AVxPlWEuBViQW0RLrg6WFJLiO5ZPpapj 1um2TubOYx4FFRhSwiKbeIarBn8AjrfvIQnMYuO3fh7ETrR3x4b5NUcecYl9UXqi8GiK/3CEK TqinlP4po7jFrMHwF6rvJyngY3bii6SPNTzsLXCgPAM4C9scOBbzXB1ZI7dqYTXnOtUF8Rrh9 O6fNxwnFrz6MWvNF/g78FnCfVbAfKfY6axmmaqcojS7RrFPORMY83cKQb4jPmWIMqa/38Q3/v lw/wUvO88/gDOWzcPCckhsVFceq8REVuYqsDFjhpaz7nIyBUz+jeuzjBnRB4CLVB4X1vyHG4G 2wfx2hs4dr4pDhBKrSmncrsANWVJ4YxoUdkEmGyVL49dAks05jW7wxNze0X4aSLZZfRTooeFa EZood7q02t5vJSEp5fbZraZ/SLUdJowt7Lu6Xvb8nxKX8RhztOZEZeAUBFpWfkY4Wz9tH+4MP g4F2ujcPY2xb6H6bMcQwSEt62NzmgFQHwcAq88nrpJHZGQRsxH8u7jKgmvPx1boyy9NLbP6K1 fm0Z0oH9l9pojcUKMn6JZ4q+duEdu8p0QOWTBpKOsTyIYIi+p9hGrKHC4I5o4eexEWjAQ+cBn +KS8NknLehvA1/uOhCuPJ5CrdA/9cnxjqAW0oB4nGXj6kImR7MYL0sxgGlnJXW8HSFy9RomP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.187 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121423 Archived-At: Am 02.09.19 um 15:43 schrieb tomas@tuxteam.de: > On Mon, Sep 02, 2019 at 09:29:39AM -0400, Stefan Monnier wrote: >>> is there a recommended way to replace element x at index i of somelist >>> y by newelement? >> What Thomas is hinting at with his "copy-list" and "functional sector" >> is that if you need to do that, there's a problem upstream. >> E.g. could you use a struct instead of a list? > Thanks for putting my mumbling into civilised words :-) > > Cheers > -- t Hmm, what means struct here? Tried a little program to answer a quiz in https://www.futurelearn.com/courses/how-computers-work/4/steps/551852/questions/3: ;; If the head is in state A at the position shown below, what would the final output of this Turing machine be? ;; |0|0|0|0|1|1|0|0|0| ;;                ^ Started that way: [leaving out here z_B - z_E] (defun z_A (zeichen pos)   ;; Char: 1 (49, #o61, #x31)   (when (eq 49 (aref zeichen pos))     (aset zeichen pos 48)     (z_B zeichen (1- pos)))) (defun zeichenmachine ()   (interactive)   (let ((zeichen "000011000")     (pos 5))     (message "%s" zeichen)     (z_A zeichen pos))) But that was easier to read: [leaving out here state_B - state_E] (defun state_A (elist pos)   (if (eq 1 (nth pos elist))       (progn     (setf (nth pos elist) 0)     (state_B elist (1- pos)))     (message "Fertig %s" elist))) (defun statemachine ()   (interactive)   (let ((elist (list 0 0 0 0 1 1 0 0 0))     (pos 5))     (state_A elist pos)))