GNU bug report logs -
#21782
25.0.50; New functions nfront/front
Previous Next
Reported by: Tino Calancha <f92capac <at> gmail.com>
Date: Thu, 29 Oct 2015 09:55:01 UTC
Severity: wishlist
Found in version 25.0.50
Done: Tino Calancha <tino.calancha <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
> I think this is already available in core as seq-take, from the seq package.
Thank you, you are right. Indeed, I found seq-take very nice:
its more general because apply to sequences.
There is one small difference: seq-take has no optional arguments.
In addition, seq.el need to be loaded by the user. Yeah, not a big
deal, but IMO such fundamental operation on a list as nfront
implement, deserve to be available at the starting of the session.
Putting a dedicated function in subr.el we save to load many stuff from
seq.el that maybe we dont need.
I would like nfront/front would behave as nbutlast/butlast concerning
the N argument:
*) N nil giving same output as N = 1.
*) N <= 0 return the full list.
(I choose the name of the function to somehow reflect such symmetry).
I have modified my patch to accomplish such behaviour.
With the new patch
(let ((ltest '(1 2 3 4 5 6)))
(nbutlast ltest nil))
(1 2 3 4 5)
(let ((ltest '(1 2 3 4 5 6)))
(nfront ltest nil))
(1)
(require 'seq)
(let ((ltest '(1 2 3 4 5 6)))
(seq-take ltest nil)); error: second argument is not optional
(let ((ltest '(1 2 3 4 5 6)))
(nbutlast ltest 0))
(1 2 3 4 5 6)
(let ((ltest '(1 2 3 4 5 6)))
(nfront ltest 0))
(1 2 3 4 5 6)
(let ((ltest '(1 2 3 4 5 6)))
(seq-take ltest 0))
nil
(let ((ltest '(1 2 3 4 5 6)))
(nbutlast ltest -1))
(1 2 3 4 5 6)
(let ((ltest '(1 2 3 4 5 6)))
(nfront ltest -1))
(1 2 3 4 5 6)
(let ((ltest '(1 2 3 4 5 6)))
(seq-take ltest -1))
nil
(let ((ltest '(1 2 3 4 5 6)))
(nbutlast ltest 20))
nil
(let ((ltest '(1 2 3 4 5 6)))
(nfront ltest 20))
(1 2 3 4 5 6)
(let ((ltest '(1 2 3 4 5 6)))
(seq-take ltest 20))
(1 2 3 4 5 6)
[subr-2.patch (text/plain, attachment)]
This bug report was last modified 8 years and 63 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.