freenode/#lisp - IRC Chatlog
Search
1:17:36
aeth
It looks like people talked about the topic 2-3 times in the past year here. https://irclog.tymoon.eu/freenode/%23lisp?from=2018-05-16T21%3A15%3A14&to=2019-05-17T09%3A15%3A14&search=remove-if-not&by
1:17:50
no-defun-allowed
remove-if and remove-if-not are extraneous just do (loop for item in list when (funcall test item) collect item)
1:19:08
aeth
no-defun-allowed: Is there a vector-equivalent to collect, though? remove-if is sequence-generic, not a list function.
1:20:04
aeth
no-defun-allowed: Just as a heuristic... you will probably need two implementations for any sequence function since what's best for lists and what's best for vectors tend to be different.
1:21:21
aeth
That's because removing from the middle of a vector is messy if you have to keep the order (if order doesn't matter you just move the last element into the removed element's spot)
1:22:57
aeth
If order didn't matter it would just be (subseq foo 0 (- length-foo (1+ matches))) and then overwrite the matches in the copy with the stuff that didn't get copied
1:24:06
aeth
With order mattering you'll have to make a new list at the size of (- length-foo (1+ matches)) and then, in a second iteration, copy element-by-element if not a match afaik.
1:25:31
no-defun-allowed
is vector-push-extend usually O(1)? could use an adjustable vector and guess the size (eg 1/2 the original)
1:26:06
Bike
usually it's amortized constant time, i think. assuming nothing weird happens with the allocation anyway
1:27:38
aeth
With my approach I guess the second loop would be something like this: (loop :for item :in original :with i := 0 :when (funcall test item) :do (progn (setf (aref new-vector i) item) (incf i)))
1:28:37
aeth
It would be complicated a bit because the type would have to match and there are a lot of 1D array types
5:46:53
no-defun-allowed
If I destroy a thread (using bordeaux-threads), will locks it held be freed?
6:15:38
asarch
"Welcome to LDB, a low-level debugger for the Lisp runtime environment."?: http://paste.scsys.co.uk/584521
6:16:19
no-defun-allowed
to my knowledge, :gc does nothing but it's valid because of &allow-other-keys
10:14:49
no-defun-allowed
minion: memo to heisig: I'm not sure if I'll be awake when you come online but happy third birthday to Petalisp!