freenode/#lisp - IRC Chatlog
Search
21:19:37
pjb
aeth: (length (remove-if-not (function symbol-plist) (let (l) (dolist (p (list-all-packages) (remove-duplicates l)) (do-symbols (s p) (push s l)))))) #| --> 306 |#
3:49:18
russellw
FAQ: 'If using REMOVE and DELETE to filter a sequence, don't use the :test-not keyword or the REMOVE-IF-NOT or DELETE-IF-NOT functions. Use COMPLEMENT to complement the predicate and the REMOVE-IF or DELETE-IF functions instead.' - a curious recommendation. Is there a reason for it?
6:29:16
jackdaniel
conceptually remove-if-not is simpler to me (but name is unfortunate - it should be FILTER) - so it picks elements matching the predicate
1:20:40
no-defun-allowed
so to really be in good form, your code better not use remove-if-not or importing outside defpackages :P
1:26:49
aeth
So do you do (remove-if (complement #'evenp) #(1 2 3 4)) and future-proof your code against a removal that probably won't happen or do you do (remove-if-not #'evenp #(1 2 3 4)) and get a faster program?
14:15:56
lukego
Verilisp looks awesome in the ECLM sense. Like somebody who wanted to build hardware just decided to use Lisp and bloody well did it. Code looks funky to a Lisper though :-) giving closing parens their own lines like C braces, defining functions like REMOVE-IF-NOT and EXPT with comments thinking they are not already built in..
16:39:31
jackdaniel
this is a good question for clschool (again ,p). remove-if-not takes two arguments: a predicate and a sequence
16:40:43
jackdaniel
so remove-if-not returns a sequence with all elements in it which met the predicate
16:43:53
pfdietz
One thing to be clear about: remove-if-not is nondestructive. It does not modify its argument (although the return value may share structure with that argument).
16:44:37
jackdaniel
mrblack: remove-if-not applies function at-loc-p to elements which are in the second argument
16:52:19
pfdietz
remove-if-not calls at-loc-p on each element of the sequence. For each call, obj is bound to that element.
17:02:09
Bike
remove-if-not calls its function argument on each element of the list it's given in the same way. so that's where the obj argument comes from.
17:05:58
Bike
No. Listen. (remove-if-not #'at-loc-p objs) is a function call. the REMOVE-IF-NOT function receives two arguments, #'at-loc-p and objs. #'at-loc-p is a function and an argument. that's the "function argument" i meant.
17:06:26
Bike
So with (remove-if-not #'at-loc-p objs), remove-if-not will call the at-loc-p function on each element of the objs.
17:24:38
pfdietz
Execution falls down into the body of the labels form, which is the call to remove-if-not. THAT function then calls at-loc-p on each element of the sequence objs.
17:25:28
pfdietz
And the value returned by the call to remove-if-not is the value returned by the labels form, and then from the call to objects-at.
21:44:17
it3ration
The names of things seem super antiquated compared to Clojure (aka, remove-if-not instead of filter, etc)
7:46:27
beach
"The names of things seem super antiquated compared to Clojure (aka, remove-if-not instead of filter"
19:35:27
phoe
I can do it via (remove-if-not (curry #'eql thing) list) but I wonder if there's a shorter way.
0:56:24
aeth
(remove-if-not is the subject of an intense tabs-vs-spaces-level debate over whether or not it should be used because it is probably the most common of the deprecated functions)
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)