Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

But, for my own part, it was Greek to me. -- William Shakespeare, "Julius Caesar"


comp / comp.lang.lisp / Re: remove-elements-not-satisfying-the-predicate

SubjectAuthor
* remove-elements-not-satisfying-the-predicateB. Pym
`* Re: remove-elements-not-satisfying-the-predicateKaz Kylheku
 `* Re: remove-elements-not-satisfying-the-predicatePaul Rubin
  `* Re: remove-elements-not-satisfying-the-predicateKaz Kylheku
   `- Re: remove-elements-not-satisfying-the-predicatePaul Rubin

1
Subject: remove-elements-not-satisfying-the-predicate
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 00:42 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: remove-elements-not-satisfying-the-predicate
Date: Wed, 3 Jul 2024 00:42:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <v626pj$1rui7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Wed, 03 Jul 2024 02:42:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1439b84b29baa786e04afeccb1cf6774";
logging-data="1964615"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SVx8Uf1H3ptwswR4JP5h0"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:x5OxM6Hb5eMRw9kKyH7EITaTIPE=
View all headers

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".

* (remove-if-not 'oddp '(0 2 3 5))

(3 5)

* (simple-remove-if-not 'oddp '(0 2 3 5))

(0 2)

See? The high and mighty CL (COBOL-like) guru got it wrong.
Of course, he probably didn't test it. He has said that
he doesn't have CL (COBOL-like) installed on his computer.
It's not worth installing.

Subject: Re: remove-elements-not-satisfying-the-predicate
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 01:02 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: remove-elements-not-satisfying-the-predicate
Date: Wed, 3 Jul 2024 01:02:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <20240702175036.784@kylheku.com>
References: <v626pj$1rui7$1@dont-email.me>
Injection-Date: Wed, 03 Jul 2024 03:02:17 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="30e244ac737476d78edd2cd6194d0a15";
logging-data="1967023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19IRIxFQ70g1dLj0IJrnQz1xAJLRkDtV7w="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:KYczZi9OXnjEnfXkks/TFHSPzqM=
View all headers

On 2024-07-03, B. Pym <No_spamming@noWhere_7073.org> wrote:
> 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".

Although it is a verbose name, which contains a double negative
(removing is negative, as is "not") Scheme's name is completely idiotic.

Filtering is an activity in which we separate a mixture into
material that is wanted and that is unwanted.

The name filter doesn't tell me what is returned: the wanted
material or the unwanted material?

Sometimes what you want is captured in a filter (e.g. cleaned
vegetables in a strainer). Sometimes the unwanted material is captured
in a filter; what passes through is what you want: e.g. cleaner air.

So even if we specify that the result of filtering something is that
which is trapped in the filter, that doesn't inform us whether that
material is what we want to keep.

If "filter" has to be in the name, you want names like filter-for and
filter-out. Filter for this condition (what we want to keep). Filter
out on this condition (what we want to reject). GNU make has
$(filter-out ...). Unfortunately, it pairs that with $(filter ...).

A much better name is keep-if, which is what I used in TXR Lisp.
It complements remove-if. A user contributed a function called
separate which returns the keep-if and remove-if results together.

separate is a synonym for filter; it would be justifiable for separate
to be called filter.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: remove-elements-not-satisfying-the-predicate
From: Paul Rubin
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 02:20 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.lisp
Subject: Re: remove-elements-not-satisfying-the-predicate
Date: Tue, 02 Jul 2024 19:20:45 -0700
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <877ce3jjwi.fsf@nightsong.com>
References: <v626pj$1rui7$1@dont-email.me> <20240702175036.784@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 03 Jul 2024 04:20:46 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="88cddf8af9c7125058ea83d38371ccbd";
logging-data="2113380"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/q8a0iXQvvb7ipoH5gzhrm"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:JqvwsfcBVMp0FdTJf3TNB7cJLpI=
sha1:EfUWzjhrzRB4b85gyTHbBWqe9e4=
View all headers

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.

Subject: Re: remove-elements-not-satisfying-the-predicate
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 02:54 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: remove-elements-not-satisfying-the-predicate
Date: Wed, 3 Jul 2024 02:54:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <20240702194136.679@kylheku.com>
References: <v626pj$1rui7$1@dont-email.me> <20240702175036.784@kylheku.com>
<877ce3jjwi.fsf@nightsong.com>
Injection-Date: Wed, 03 Jul 2024 04:54:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="30e244ac737476d78edd2cd6194d0a15";
logging-data="2115877"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+I6M74nvhP6dT0VGx6mfJaQ65ALbB+Ojg="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:Cd2Cwei2FZDJ22ZYO2Nh3IyN8QI=
View all headers

On 2024-07-03, Paul Rubin <no.email@nospam.invalid> wrote:
> 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.

Electronics filters (at least simple, passive ones like one-pole RC)
have only one output. There is no tap for the "filtered out" signal.

The "high pass" term alone tells you what passes onto that one and only
output.

"pass" would be an okay name for the function:

(pass (lambda (x) (> x 3)) list)

(reject (lambda (x) (> x 3)) list)

It's a "high pass filter" and not just a "high filter" because
the latter makes it unclear whether highs are rejected or passed!

It could be interpreted similarly to "UV filter" or "dust filter".

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: remove-elements-not-satisfying-the-predicate
From: Paul Rubin
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 20:27 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.lisp
Subject: Re: remove-elements-not-satisfying-the-predicate
Date: Wed, 03 Jul 2024 13:27:46 -0700
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <8734oqjk59.fsf@nightsong.com>
References: <v626pj$1rui7$1@dont-email.me> <20240702175036.784@kylheku.com>
<877ce3jjwi.fsf@nightsong.com> <20240702194136.679@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 03 Jul 2024 22:27:46 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="88cddf8af9c7125058ea83d38371ccbd";
logging-data="2478755"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JCMTyVG1/sIRZv0TD0xY2"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:5Z0R+pQPkn22QCR1PZncYATbrn0=
sha1:jPk2VFVxdQT9nb+wH529Gk1d8f8=
View all headers

Kaz Kylheku <643-408-1753@kylheku.com> writes:
> Electronics filters (at least simple, passive ones like one-pole RC)
> have only one output. There is no tap for the "filtered out" signal.

A filter that lets you collect the rejected material is called a sieve.

1

rocksolid light 0.9.8
clearnet tor