Enze Chi
Enze Chi

Reputation: 1753

what's difference between 'delete' and 'remove' in Emacs Lisp

I am learning Elisp by reading others' code. Then I found people use both delete and remove to delete element from sequence. I checked the document and the code of remove it seams just a wrapper for delete which when the sequence is a list, do a copy-sequence.

Is it really matter to copy list to do the delete? Or I can just use delete which is a C command which should be more efficient I think.

Upvotes: 1

Views: 528

Answers (1)

Ulrich Schwarz
Ulrich Schwarz

Reputation: 7727

remove returns

a copy of seq with all occurrences of elt removed.

whereas delete

delete[s] by side effect any occurrences of elt as a member of seq.

so it modifies the original sequence. (Unless the first element is a hit, so pleasee consult C-hf delete for full details.)

Upvotes: 4

Related Questions