From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tpeplt Newsgroups: gmane.emacs.help Subject: Re: List not getting filled up Date: Sun, 30 Jul 2023 10:28:11 -0400 Message-ID: <87sf95lbic.fsf@gmail.com> 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="7700"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cc: To: uzibalqa Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 30 16:33:58 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 1qQ7Uc-0001hn-Ak for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 30 Jul 2023 16:33:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQ7P8-0001KC-LR; Sun, 30 Jul 2023 10:28:18 -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 1qQ7P6-0001IY-4Y for help-gnu-emacs@gnu.org; Sun, 30 Jul 2023 10:28:16 -0400 Original-Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQ7P4-000374-Ka for help-gnu-emacs@gnu.org; Sun, 30 Jul 2023 10:28:15 -0400 Original-Received: by mail-qv1-xf36.google.com with SMTP id 6a1803df08f44-6378cec43ddso18382676d6.2 for ; Sun, 30 Jul 2023 07:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690727293; x=1691332093; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=LFAY4bJXLAs+W11KGpg/EqTzTUoNqac3XLBj9MGu/SY=; b=dSGQ8eMLKjC1tpQTMg7zv+sth2ARCPyD7LRPjTWpKAaymO2j3G4D6UsQumcAoZUAnk zW6lJFrgHV3serwcIkJLrUf6nWNG8Rvzloa44LCnxsEmIUCYmGzVz/JdrbR+nsKudM1U WnPydyfqf2scvP7VzxpZK+5lWiagqvyfbkSY14jSmrab0Q8msSoFT1c+T45Ob7gXgc34 m/MU+liQbiKIDp4dMELbxKclIXaR8dhxjXaJZNX2PXxDe6yxOq24D0KGDLxalM9I2Izg 7hdOppUItcI3SY3jXkh0A0TkoxLyAW9/11WaqGBOkEMn9xc5hdHPol+vWk9Qw3rSWiiF M+cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690727293; x=1691332093; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LFAY4bJXLAs+W11KGpg/EqTzTUoNqac3XLBj9MGu/SY=; b=F3VOLUQYYjSjZEDsIqDyUk/UoJXUG6VMZLkm6oVs12ToBU4Ja/Yw+DfsA9jONAproK 0S5vuIhIkAYZVUOndN17tSxmrO2AVIA4BAGB1jXji9kDECoNEAW9iHNhGitM+adnJ8Qz qMivn7XTRvy3o63Bs4jGR1Sdkj6z7Yn1JV+z+SsalLxQMqKrly4NO2Bogm3PH4pvSh/d kTu+qqEJ/vCMfgK0oHFulkQKiu11+9Ma6NmH7JNt/1rBKS4Xz8qd21UuKKlY7BJF/zpf af2kBUeZgISkA/vER3+fvdxG+7RinxdMkZBMI7qhT9eMsGcJjgUCCHuMjpguppq4GdVT vMWg== X-Gm-Message-State: ABy/qLZX20UDSdYWV3zvAT/K8+iSf5NioHiYgXpyHaKb55Ke9B3oYNtK dqeYMvoB74Ge2rlh4aSJhzI= X-Google-Smtp-Source: APBJJlGgGlqwDfxQxgckm4s4xl1Y4H4uqh8rNQbMtYh4/6DGC1HwgjFxgHAuD/a7m8g9GhgcMK193g== X-Received: by 2002:a05:6214:e86:b0:63d:3abe:162b with SMTP id hf6-20020a0562140e8600b0063d3abe162bmr8690553qvb.38.1690727293063; Sun, 30 Jul 2023 07:28:13 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a821:2b00::123a]) by smtp.gmail.com with ESMTPSA id o16-20020a0cf4d0000000b0063d385c28edsm2938089qvm.41.2023.07.30.07.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 07:28:12 -0700 (PDT) In-Reply-To: (uzibalqa@proton.me's message of "Fri, 28 Jul 2023 23:21:42 +0000") Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=tpeplt@gmail.com; helo=mail-qv1-xf36.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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:144497 Archived-At: uzibalqa writes: > I have the recursive function 'permutor'. When the condition '(<=3D k 1)= ' is reached I add > word to the list 'mylist'. I only get one value, yet the '(message "%s" = word)' give me all > the words that I need. What is happening and what can I do ? > > (defvar mylist '()) > > (defun permutor (k word) > "Generate all permutations of WORD." > > (let ( (i 0) ) > > (if (<=3D k 1) > (progn > (message "%s" word) > (add-to-list 'mylist word)) > > (while (< i k) > (permutor (1- k) word) > > (if (evenp i) ; even integer > (setq word (swap word i (1- k))) > > (setq word (swap word 0 (1- k)))) > > (setq i (1+ i)))) ) > > word) 1. Provide a specification of the problem that you want your procedure to solve. For example, provide calls to your procedure with a range of values and the results that you want your procedure to produce: (permutor 0 'aword) should yield =3D> what? (permutor 1 'aword) should yield =3D> what? (permutor 5 'aword) should yield =3D> what? (permutor 9 'aword) should yield =3D> what? 2. Compiling an Emacs Lisp file can provide useful information about possible problems with the code. Once an Emacs Lisp buffer has been saved to a file (usually with the filename extension ".el"), it can be compiled using the "Byte-compile This File" menu entry in the Emacs-Lisp menu. Alternatively, you can use the command M-x byte-compile-file. When this is done on your code, the compiler tells you that the function =E2=80=98swap=E2=80=99 is not known to be defined. 3. Emacs provides =E2=80=98edebug=E2=80=99, a debugger which allows you to= step through your code, examining values of variables as you go so that you can compare what you expect to happen with what is happening. To use edebug, you will need to "instrument" the procedure that you want to step through and then invoke the procedure with your desired arguments. Again, the Emacs-Lisp menu provides a menu entry for you to do this, "Instrument Function for Debugging", and it documents that you can do this using the keystroke combination C-u C-M-x (when point is located in the procedure). An introduction to edebug can be found in the Introduction to Emacs Lisp, which can be read via the menu path: Help -> More Manuals -> Introduction to Emacs Lisp. Or, you can go directly to the debugging section with the command: M-: (info "(eintr) Debugging") The full documents on Emacs two debuggers can be read in the Emacs Lisp reference manual M-: (info "(elisp) Debugging") --