|
From: | Drew Adams |
Subject: | RE: [External] : Re: Easy to add with push but not to the end of a list |
Date: | Mon, 28 Nov 2022 21:56:35 +0000 |
> Why is the below O(N), because of `last'? > > (defun push-last (elem lst) > (let ((elem-lst (list elem))) > (if lst > (setcdr (last lst) elem-lst) > (setq lst elem-lst) ) > lst) ) Yes. (append lst (list elem)) also traverses the list usually.
[Prev in Thread] | Current Thread | [Next in Thread] |