[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [External] : Re: Testing whether a list contains at least one non-ni
From: |
Jean Louis |
Subject: |
Re: [External] : Re: Testing whether a list contains at least one non-nil element |
Date: |
Thu, 27 Oct 2022 07:53:09 +0300 |
User-agent: |
Mutt/2.2.7+37 (a90f69b) (2022-09-02) |
* Drew Adams <drew.adams@oracle.com> [2022-10-27 06:54]:
> ;; Why do the rest of this?
> ;; Search for a nil, after the non-nil car?
> ;; Then copy the entire list. Then delete
> ;; all nils from it? Why on earth do this?
> (if (memq elt list)
> ^^^^
> (delq elt (copy-sequence list))
> ^^^^^^^^^^^^^
> ^^^^^^^^^
> list))
I get your reasoning. Maybe my function was not named correctly and
then your logic jumps in.
> You certainly don't need to remove all nils
> from the list. If your list is 100,000,000
> elements long and the first element is t, why
> would you want to copy the entire list and
> then remove all the nils from it? Testing
> the first element tells you the answer.
I get the reasoning, you are right, though maybe not in the context of
testing if list has at least one non nil element. I am not sure, you
know is not easy to grasp all.
What I know is that by testing the first element does not tell the
answer if list has any non nil element:
(let ((my-list '(nil nil nil nil)))
(car my-list)) ⇒ nil
(let ((my-list '(nil nil nil nil 1)))
(car my-list)) ⇒ nil
So testing the first element did not give me the answer that
my-list has one non-nil element.
Maybe you can show in Emacs Lisp practically how do you mean it.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Testing whether a list contains at least one non-nil element, Heime, 2022/10/25
- Re: Testing whether a list contains at least one non-nil element, Jean Louis, 2022/10/25
- Re: Testing whether a list contains at least one non-nil element, Jean Louis, 2022/10/25
- Re: Testing whether a list contains at least one non-nil element, Jean Louis, 2022/10/25
- Re: Testing whether a list contains at least one non-nil element, Emanuel Berg, 2022/10/26
- Re: Testing whether a list contains at least one non-nil element, Jean Louis, 2022/10/26
- RE: [External] : Re: Testing whether a list contains at least one non-nil element, Drew Adams, 2022/10/26
- Re: [External] : Re: Testing whether a list contains at least one non-nil element,
Jean Louis <=
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Emanuel Berg, 2022/10/27
- RE: [External] : Re: Testing whether a list contains at least one non-nil element, Drew Adams, 2022/10/27
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Jean Louis, 2022/10/27
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, tomas, 2022/10/28
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Jean Louis, 2022/10/28
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Michael Heerdegen, 2022/10/28
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Stefan Monnier, 2022/10/28
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Michael Heerdegen, 2022/10/29
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Stefan Monnier, 2022/10/29
- Re: [External] : Re: Testing whether a list contains at least one non-nil element, Emanuel Berg, 2022/10/30