all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Generic sequences in seq.el
Date: Sat, 22 Dec 2018 21:04:59 -0500	[thread overview]
Message-ID: <CAO0xp5yfkZq84ZQGOU_1bcgL8-RQvpRf8g4EVabP3kK2Fp4Krg@mail.gmail.com> (raw)
In-Reply-To: <jwv8t0jj76j.fsf-monnier+gmane.emacs.devel@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]

>   (seq-concatenate 'list (seq-subseq seq 0 n)
>                          (list element)
>                          (seq-subseq seq n))

That returns a list, not the sequence. So inserting something into the
sequence
makes it not a sequence anymore?

> We currently don't have any data-structure that can be efficiently
> modified in-place via push/pop (note that even lists don't qualify
> because push/pop doesn't modify the list in place: they replace a list
> with another without modifying any existing list (unless the PLACE is
> the car/cdr of a list, of course, but that's a separate issue)).

Thanks, it's good to know.

Yuan.

On Fri, Dec 21, 2018 at 9:24 AM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >     (setf (nthcdr n seq) (cons element (nthcdr n seq)))
> > to insert element into the nth position in seq
>
> I think with `seq` you'd do something like
>
>    (seq-concatenate 'list (seq-subseq seq 0 n)
>                           (list element)
>                           (seq-subseq seq n))
>
> Of course, it's different because it's non-destructive, but insertion
> into an array can't be done non-destructively anyway.
>
> > The idea is I'll implement this function for the generic sequence
> > that I'll define in the future. Is that a correct approach?
> > Other destructive functions that I couldn't find alternatives are delete,
> > push, pop, etc.
>
> We currently don't have any data-structure that can be efficiently
> modified in-place via push/pop (note that even lists don't qualify
> because push/pop doesn't modify the list in place: they replace a list
> with another without modifying any existing list (unless the PLACE is
> the car/cdr of a list, of course, but that's a separate issue)).
>
>
>         Stefan
>
>
>

[-- Attachment #2: Type: text/html, Size: 4637 bytes --]

  reply	other threads:[~2018-12-23  2:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21 11:42 Generic sequences in seq.el Yuan Fu
2018-12-21 14:24 ` Stefan Monnier
2018-12-23  2:04   ` Yuan Fu [this message]
2018-12-23 14:34     ` Stefan Monnier
2019-01-08  4:12       ` Yuan Fu
2019-01-08 15:01         ` Stefan Monnier

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=CAO0xp5yfkZq84ZQGOU_1bcgL8-RQvpRf8g4EVabP3kK2Fp4Krg@mail.gmail.com \
    --to=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.