In article ... (Christopher Dollin) writes:
So suppose someone says "please implement 'remove-if-not'. I would like >your solution to generate no garbage if possible and to be reasonably >efficient".
Here's a version I threw together quickly (note that it doesn't take
any options as the CL version does, and it only accepts a list, not
any sequence):
(defun simple-remove-if-not (test list)
(let ((result nil))
(dolist (item list)
(unless (funcall test item)
(push item result)))
(nreverse result)))
Barry Margolin wrote:
In article ... (Christopher Dollin) writes:
So suppose someone says "please implement 'remove-if-not'. I would like
your solution to generate no garbage if possible and to be reasonably
efficient".
Here's a version I threw together quickly (note that it doesn't take
any options as the CL version does, and it only accepts a list, not
any sequence):
(defun simple-remove-if-not (test list)
(let ((result nil))
(dolist (item list)
(unless (funcall test item)
(push item result)))
(nreverse result)))
What an egregiously bad name: "remove-if-not"
Scheme uses the sensible "filter".
Kaz Kylheku <643-408-1753@kylheku.com> writes:
The name filter doesn't tell me what is returned: the wanted
material or the unwanted material?
The term has been around forever, like in electronics: high pass
filters, low pass filters, etc. It's almost always the wanted material
that comes out of the filter.
The name filter doesn't tell me what is returned: the wanted
material or the unwanted material?
Electronics filters (at least simple, passive ones like one-pole RC)
have only one output. There is no tap for the "filtered out" signal.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 438 |
Nodes: | 16 (2 / 14) |
Uptime: | 246:30:40 |
Calls: | 9,145 |
Calls today: | 1 |
Files: | 13,432 |
D/L today: |
1 files (2,685K bytes) |
Messages: | 6,040,270 |