all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* List not getting filled up
@ 2023-07-28 23:21 uzibalqa
  2023-07-29 11:19 ` Emanuel Berg
  2023-07-30 14:28 ` tpeplt
  0 siblings, 2 replies; 14+ messages in thread
From: uzibalqa @ 2023-07-28 23:21 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor

I have the recursive function 'permutor'.  When the condition '(<= 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 (<= 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)



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-07-31  8:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 23:21 List not getting filled up uzibalqa
2023-07-29 11:19 ` Emanuel Berg
2023-07-30 14:28 ` tpeplt
2023-07-30 14:47   ` uzibalqa
2023-07-30 17:42     ` Yuri Khan
2023-07-31  0:06       ` uzibalqa
2023-07-31  8:55         ` Yuri Khan
2023-07-31  0:50       ` [External] : " Drew Adams
2023-07-31  1:08         ` uzibalqa
2023-07-31  1:29           ` Drew Adams
2023-07-31  1:34             ` uzibalqa
2023-07-31  1:40               ` Drew Adams
2023-07-31  2:03                 ` uzibalqa
2023-07-31  2:59                   ` Heime

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.