[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Re: Setting up abbrev
From: |
Drew Adams |
Subject: |
RE: [External] : Re: Setting up abbrev |
Date: |
Mon, 1 Aug 2022 16:36:23 +0000 |
> >> Only a pair is a list as well ...
> >
> > Yes. But a list isn't a pair. ;-)
>
> Every pair is a list but every list isn't a pair ...
|
not every list is a pair
"Not every X is" = "some X isn't" != "every X isn't"
> Well, maybe one can think of a pair without order, i.e.
> a set of two items?
>
> The _ordered_ pair is the universal data structure that can
> express anything then. The list is equally universal but the
> ordered pair is the minimal working example, to speak with the
> LaTeX guys ...
Yes, ordered pair. That's a cons.
> > As for the (a . b) _notation_: Why not? JSON uses `:'.
> > Prolog uses `|'. Doesn't matter much what notation you
> > choose. OOPs often use a dot notation for method
> > application. Six of one; half a dozen of another...
>
> Okay, but I still don't understand the benefit of using it in
> practice compared to the list (a b)?
Do you mean use the _notation_? I guess you instead
mean use a dotted list: a list whose last cdr is a
non-nil atom.
If so, the answer is that in general you do want to
use a true/proper list (last cdr is nil), and NOT a
dotted list. For many reasons, not least of which
is using a function that needs to traverse all list
elements (e.g. `length', mapping/sequence functions).
You can use a dotted list in these cases:
1. You want to save conses (not create so many), in
a context where you're not going to be needing to
use the cons as a list (mapping etc.), or a context
where you know you'll only ever want an atom cdr.
2. You want/need, in effect, to have a backwards
key-value pair, (list-value . atom-key). You have
a list to use for most purposes (ignoring the last
cdr), and you have an atom (the cdr) for a few rare
purposes, as a kind of label for the list.
#2 is usually the result of trying to adapt to
legacy code that expects to treat just a list (and
doesn't need to follow it to its end). IOW, #2 is
typically an ugly hack. For new code you'd instead
just put the atom first: (atom-key . list-value).
- Re: Setting up abbrev, Jean Louis, 2022/08/01
- Re: Setting up abbrev, Jean Louis, 2022/08/01
- Re: Setting up abbrev, uzibalqa, 2022/08/01
- Re: Setting up abbrev, Emanuel Berg, 2022/08/01
- RE: [External] : Re: Setting up abbrev, Drew Adams, 2022/08/01
- Re: [External] : Re: Setting up abbrev, Emanuel Berg, 2022/08/01
- RE: [External] : Re: Setting up abbrev,
Drew Adams <=
- RE: [External] : Re: Setting up abbrev, wilnerthomas, 2022/08/01
- Re: [External] : Re: Setting up abbrev, Emanuel Berg, 2022/08/01
- RE: [External] : Re: Setting up abbrev, Drew Adams, 2022/08/01
- Re: Setting up abbrev, tomas, 2022/08/01
- Re: Setting up abbrev, Emanuel Berg, 2022/08/01
- Re: Setting up abbrev, tomas, 2022/08/01
Re: Setting up abbrev, carlmarcos, 2022/08/01