branch: externals/dash commit 096f244187dcd02f4157df4c2067d5e6e3c7e4cf Author: Matus Goljer <matus.gol...@gmail.com> Commit: Matus Goljer <matus.gol...@gmail.com>
--remove-last does not modify input list #158 --- dash.el | 2 +- dev/examples.el | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dash.el b/dash.el index f310563..7c8ed69 100644 --- a/dash.el +++ b/dash.el @@ -270,7 +270,7 @@ See also: `-remove', `-map-first'" Alias: `-reject-last' See also: `-remove', `-map-last'" - (nreverse (-remove-first pred (nreverse list)))) + (nreverse (-remove-first pred (reverse list)))) (defmacro --remove-last (form list) "Anaphoric form of `-remove-last'." diff --git a/dev/examples.el b/dev/examples.el index 06bc58f..7fa8528 100644 --- a/dev/examples.el +++ b/dev/examples.el @@ -131,7 +131,10 @@ new list." (defexamples -remove-last (-remove-last 'even? '(1 3 5 4 7 8 10 11)) => '(1 3 5 4 7 8 11) (-remove-last 'stringp '(1 2 "last" "second" "third")) => '(1 2 "last" "second") - (--remove-last (> it 3) '(1 2 3 4 5 6 7 8 9 10)) => '(1 2 3 4 5 6 7 8 9)) + (--remove-last (> it 3) '(1 2 3 4 5 6 7 8 9 10)) => '(1 2 3 4 5 6 7 8 9) + ;; the next two tests assert that the input list is not modified #158 + (let ((l '(1 2 3))) (list (--remove-last (< it 2) l) l)) => '((2 3) (1 2 3)) + (let ((l '(1 2 3))) (list (--remove-last (< it 4) l) l)) => '((1 2) (1 2 3))) (defexamples -remove-item (-remove-item 3 '(1 2 3 2 3 4 5 3)) => '(1 2 2 4 5)