[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master d62766305a: Add `take` and `ntake` (bug#56521)
From: |
Mattias Engdegård |
Subject: |
Re: master d62766305a: Add `take` and `ntake` (bug#56521) |
Date: |
Mon, 18 Jul 2022 12:59:51 +0200 |
18 juli 2022 kl. 10.48 skrev Robert Pluim <rpluim@gmail.com>:
> Does this need the usual blurb to do
>
> (setq list-var (ntake 3 list-var))
>
> to ensure `list-var' is updated?
Sort of; I added some text to that effect. Using the return value is only
needed if N can be nonpositive.
> I think this would be clearer as
>
> "If N is >= the length of LIST, return LIST (or a copy)."
>
> since weʼre talking about the effect of various values of N.
Right, it's now been changed to something like that. Thank you!
Now `seq-take` uses `take`, and so does `seq-subseq`. This made both faster,
but the latter was boosted immensely by not formatting an error string up-front.
`seq-subseq` would be even faster if simply written as
(take (- end start) (nthcdr start sequence))
but the interface requirements force a much more cumbersome implementation.
(And does it really need `copy-sequence`? The docs are unclear.)
I suppose that `seq-subseq` should use `cl-defmethod` for dispatching on type
but I didn't change that part.