all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: uzibalqa <uzibalqa@proton.me>
Cc: tpeplt <tpeplt@gmail.com>, help-gnu-emacs@gnu.org
Subject: Re: List not getting filled up
Date: Mon, 31 Jul 2023 15:55:12 +0700	[thread overview]
Message-ID: <CAP_d_8UEiCvaNJ=B5yHg+EZ+x94N=JPQUEka11FrgCGfQgKNzQ@mail.gmail.com> (raw)
In-Reply-To: <ZGr_GVUnJvwFqdpjL7UyIIJoS6wCs8R4vqBtrMfdepvXdBqGFwupigDvIPuQy1nVb5oeeDZB0Zu3nBWLyuTPaTNe_FuYaK4TDVD4X7YPcqE=@proton.me>

On Mon, 31 Jul 2023 at 07:06, uzibalqa <uzibalqa@proton.me> wrote:

> Have done a non-destructive swap-chars which I use directly as follows
>
> (setq result
>           (permute (swap-chars string i j) (1+ i) length result))
>
> >  Hint 2: your second
> > ‘swap-chars’ call is only there to undo the modification made by the
> > first call, so it could be avoided by introducing a local variable to
> > hold the result of the modification.)
>
> For your second hint, I am unsure what to store.  Would I store the original
> string passed as an argument to the function as follows.  Then what would I
> do with copy of the string that war not swapped ?

If you pass the return value of ‘swap-chars’ directly into ‘permute’,
nothing additional is needed. You could alternatively use

    (let ((swapped (swap-chars string i j)))
      (setq result (permute swapped (1+ i) length result)))

in case you find that easier to read.



  reply	other threads:[~2023-07-31  8:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8UEiCvaNJ=B5yHg+EZ+x94N=JPQUEka11FrgCGfQgKNzQ@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tpeplt@gmail.com \
    --cc=uzibalqa@proton.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.