all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* append, push, and add-to-list.
@ 2021-07-04  3:18 Hongyi Zhao
  2021-07-04  4:35 ` Jean Louis
  2021-07-04 16:19 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-04  3:18 UTC (permalink / raw)
  To: help-gnu-emacs

I've noticed there are some similar functions, i.e., append, push, and
add-to-list, for revising/updating the content of a list. But I'm
still not so clear on the specific use scenarios for them. Consider
the following command [1]:

(push '(company-capf company-ispell) company-backends)

What's the equivalent representations using append and add-to-list?
Which methods are preferable?

[1] <https://github.com/company-mode/company-mode/issues/1124#issuecomment-864461337>

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04  3:18 append, push, and add-to-list Hongyi Zhao
@ 2021-07-04  4:35 ` Jean Louis
  2021-07-04  5:11   ` Hongyi Zhao
  2021-07-04 16:19 ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 38+ messages in thread
From: Jean Louis @ 2021-07-04  4:35 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-04 06:19]:
> I've noticed there are some similar functions, i.e., append, push, and
> add-to-list, for revising/updating the content of a list. But I'm
> still not so clear on the specific use scenarios for them. Consider
> the following command [1]:
> 
> (push '(company-capf company-ispell) company-backends)
> 
> What's the equivalent representations using append and add-to-list?
> Which methods are preferable?

It is recommended to review documentation for each function by using
{C-h f} -

- function add-to-list is traditionally rather used in configurations,
  how I see it, like (add-to-list 'load-path "/my/directory") or
  similar, instead, in programming code one shall rather use `push' or
  `cl-pushnew' as `add-to-list' adds only new unique elements;

Because you use it more for configurations, then add-to-list would be:

(add-to-list 'company-backends '(company-capf company-ispell))

and with append

(append company-backends '(company-capf company-ispell))



-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04  4:35 ` Jean Louis
@ 2021-07-04  5:11   ` Hongyi Zhao
  2021-07-04 11:28     ` Jean Louis
  2021-07-04 16:20     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-04  5:11 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

On Sun, Jul 4, 2021 at 12:36 PM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-04 06:19]:
> > I've noticed there are some similar functions, i.e., append, push, and
> > add-to-list, for revising/updating the content of a list. But I'm
> > still not so clear on the specific use scenarios for them. Consider
> > the following command [1]:
> >
> > (push '(company-capf company-ispell) company-backends)
> >
> > What's the equivalent representations using append and add-to-list?
> > Which methods are preferable?
>
> It is recommended to review documentation for each function by using
> {C-h f} -
>
> - function add-to-list is traditionally rather used in configurations,
>   how I see it, like (add-to-list 'load-path "/my/directory") or
>   similar, instead, in programming code one shall rather use `push' or
>   `cl-pushnew' as `add-to-list' adds only new unique elements;

Thank you. I listed the usages below for all above-mentioned functions
by {C-h f} function-name:

(add-to-list LIST-VAR ELEMENT &optional APPEND COMPARE-FN)
(push NEWELT PLACE)
(cl-pushnew X PLACE [KEYWORD VALUE]...)
(append &rest SEQUENCES)

>
> Because you use it more for configurations, then add-to-list would be:
>
> (add-to-list 'company-backends '(company-capf company-ispell))

Why can't this be written as follows, just like the other two?

(add-to-list company-backends '(company-capf company-ispell))

>
> and with append
>
> (append company-backends '(company-capf company-ispell))

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04  5:11   ` Hongyi Zhao
@ 2021-07-04 11:28     ` Jean Louis
  2021-07-04 13:50       ` Hongyi Zhao
  2021-07-04 16:20     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 38+ messages in thread
From: Jean Louis @ 2021-07-04 11:28 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-04 08:12]:
> Thank you. I listed the usages below for all above-mentioned functions
> by {C-h f} function-name:
> 
> (add-to-list LIST-VAR ELEMENT &optional APPEND COMPARE-FN)
> (push NEWELT PLACE)
> (cl-pushnew X PLACE [KEYWORD VALUE]...)
> (append &rest SEQUENCES)

Good, I can also see some possible inconsistencies with X and NEWELT,
as it would be better to call X also NEWELT. I can also see that
documentation for `cl-pushnew' is not adequate enough. You are
probably expected to learn definition from Common Lisp to understand
the KEYWORDs:
http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_pushnew.html#pushnew

Function `append' will work with various sequences not just lists.

Please see manual: (info "(elisp) Sequences Arrays Vectors")

> > Because you use it more for configurations, then add-to-list would be:
> >
> > (add-to-list 'company-backends '(company-capf company-ispell))
> 
> Why can't this be written as follows, just like the other two?
> 
> (add-to-list company-backends '(company-capf company-ispell))
> 
> >
> > and with append
> >
> > (append company-backends '(company-capf company-ispell))

Functions `add-to-list' and `append' do different things, though
similar. 


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04 11:28     ` Jean Louis
@ 2021-07-04 13:50       ` Hongyi Zhao
  2021-07-04 15:58         ` Jean Louis
  2021-07-04 16:01         ` [External] : " Drew Adams
  0 siblings, 2 replies; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-04 13:50 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

On Sun, Jul 4, 2021 at 7:32 PM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-04 08:12]:
> > Thank you. I listed the usages below for all above-mentioned functions
> > by {C-h f} function-name:
> >
> > (add-to-list LIST-VAR ELEMENT &optional APPEND COMPARE-FN)
> > (push NEWELT PLACE)
> > (cl-pushnew X PLACE [KEYWORD VALUE]...)
> > (append &rest SEQUENCES)
>
> Good, I can also see some possible inconsistencies with X and NEWELT,
> as it would be better to call X also NEWELT. I can also see that
> documentation for `cl-pushnew' is not adequate enough. You are
> probably expected to learn definition from Common Lisp to understand
> the KEYWORDs:
> http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_pushnew.html#pushnew
>
> Function `append' will work with various sequences not just lists.
>
> Please see manual: (info "(elisp) Sequences Arrays Vectors")
>
> > > Because you use it more for configurations, then add-to-list would be:
> > >
> > > (add-to-list 'company-backends '(company-capf company-ispell))
> >
> > Why can't this be written as follows, just like the other two?
> >
> > (add-to-list company-backends '(company-capf company-ispell))
> >
> > >
> > > and with append
> > >
> > > (append company-backends '(company-capf company-ispell))
>
> Functions `add-to-list' and `append' do different things, though
> similar.
>

I'm curious why `add-to-list' must take 'company-backends, i.e.,
(quote company-backends) as one of its argument, while the other
functions can directly use the unquoted form.

HY
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04 13:50       ` Hongyi Zhao
@ 2021-07-04 15:58         ` Jean Louis
  2021-07-05  2:04           ` Hongyi Zhao
  2021-07-04 16:01         ` [External] : " Drew Adams
  1 sibling, 1 reply; 38+ messages in thread
From: Jean Louis @ 2021-07-04 15:58 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-04 16:52]:
> I'm curious why `add-to-list' must take 'company-backends, i.e.,
> (quote company-backends) as one of its argument, while the other
> functions can directly use the unquoted form.

It must not. But add-to-list is by tradition older and more used
function. And it will not require cl library such as `cl-pushnew'.

I am verifying:

(type-of company-backends) ⇒ cons

(company-bbdb company-eclim company-semantic company-clang
	      company-xcode company-cmake company-capf company-files
	      (company-dabbrev-code company-gtags company-etags
	      company-keywords) company-oddmuse company-dabbrev)

This is the list, so you may use any method you wish to put elements
in the list.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 38+ messages in thread

* RE: [External] : Re: append, push, and add-to-list.
  2021-07-04 13:50       ` Hongyi Zhao
  2021-07-04 15:58         ` Jean Louis
@ 2021-07-04 16:01         ` Drew Adams
  1 sibling, 0 replies; 38+ messages in thread
From: Drew Adams @ 2021-07-04 16:01 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

> I'm curious why `add-to-list' must take 'company-backends, i.e.,
> (quote company-backends) as one of its argument, while the other
> functions can directly use the unquoted form.

It's not that it "must take" a quoted symbol as arg.
It's that takes a symbol as arg.  That symbol can be
provided any way you like, i.e., by evaluating any
sexp that results in a symbol.

It's essentially equivalent to using both a `pushnew'
and a `set' or `setq' (with a variable as PLACE).  It
sets the variable value of its symbol arg to the new
list value.

As others have said, you will do yourself a favor by
reading (even studying) the Elisp manual.

Likewise, by looking at the Elisp source code provided
with Emacs.  The source code is freely available;
consider taking advantage of that fact.

`grep' the source code and use `flush-lines' to remove
instances where the first arg to `add-to-list' is a
quoted symbol, to get a feel for its use evaluating a
sexp (other than a quoted symbol) that yields a symbol.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04  3:18 append, push, and add-to-list Hongyi Zhao
  2021-07-04  4:35 ` Jean Louis
@ 2021-07-04 16:19 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05  2:16   ` Hongyi Zhao
  1 sibling, 1 reply; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-04 16:19 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> I've noticed there are some similar functions, i.e., append,
> push, and add-to-list, for revising/updating the content of
> a list. But I'm still not so clear on the specific use
> scenarios for them. Consider the following command [1]

`nconc', `cl-pushnew', (setq lst `(,@lst el)) ...

> [...] Which methods are preferable?

Good question, perhaps in the manual somewhere they listed
and explained all in one place, if not, the help (`C-h f')
should be your friend.

But my intuition tells me, just because there are many options
a, b, ..., and z, that doesn't mean necessarily that one is
optimal for that situation.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04  5:11   ` Hongyi Zhao
  2021-07-04 11:28     ` Jean Louis
@ 2021-07-04 16:20     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-04 16:20 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> Thank you. I listed the usages below for all above-mentioned
> functions by {C-h f} function-name:
>
> (add-to-list LIST-VAR ELEMENT &optional APPEND COMPARE-FN)
> (push NEWELT PLACE)
> (cl-pushnew X PLACE [KEYWORD VALUE]...)
> (append &rest SEQUENCES)

But the syntax is probably the easy part...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04 15:58         ` Jean Louis
@ 2021-07-05  2:04           ` Hongyi Zhao
  0 siblings, 0 replies; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-05  2:04 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

On Mon, Jul 5, 2021 at 12:01 AM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-04 16:52]:
> > I'm curious why `add-to-list' must take 'company-backends, i.e.,
> > (quote company-backends) as one of its argument, while the other
> > functions can directly use the unquoted form.
>
> It must not. But add-to-list is by tradition older and more used
> function. And it will not require cl library such as `cl-pushnew'.
>
> I am verifying:
>
> (type-of company-backends) ⇒ cons
>
> (company-bbdb company-eclim company-semantic company-clang
>               company-xcode company-cmake company-capf company-files
>               (company-dabbrev-code company-gtags company-etags
>               company-keywords) company-oddmuse company-dabbrev)


See my results obtained by putting `(type-of company-backends)' in
scratch buffer, and with the point on any part of `company-backends',
then hit `M-.':

(defcustom company-backends `(company-bbdb
                              ,@(unless (version<= "26" emacs-version)
                                  (list 'company-nxml))
                              ,@(unless (version<= "26" emacs-version)
                                  (list 'company-css))
                              company-semantic
                              company-cmake
                              company-capf
                              company-clang
                              company-files
                              (company-dabbrev-code company-gtags company-etags
                               company-keywords)
                              company-oddmuse company-dabbrev)


>
> This is the list, so you may use any method you wish to put elements
> in the list.
>
> --
> Jean
>
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
>
> In support of Richard M. Stallman
> https://stallmansupport.org/



-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-04 16:19 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05  2:16   ` Hongyi Zhao
  2021-07-05  3:48     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05  5:06     ` Jean Louis
  0 siblings, 2 replies; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-05  2:16 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Mon, Jul 5, 2021 at 12:19 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > I've noticed there are some similar functions, i.e., append,
> > push, and add-to-list, for revising/updating the content of
> > a list. But I'm still not so clear on the specific use
> > scenarios for them. Consider the following command [1]
>
> `nconc', `cl-pushnew', (setq lst `(,@lst el)) ...

Does the following append `el' to `lst'?

(setq lst `(,@lst el))

>
> > [...] Which methods are preferable?
>
> Good question, perhaps in the manual somewhere they listed
> and explained all in one place, if not, the help (`C-h f')
> should be your friend.
>
> But my intuition tells me, just because there are many options
> a, b, ..., and z, that doesn't mean necessarily that one is
> optimal for that situation.

This is one of the reasons that baffles me the most - there are so
many functions in Emacs.

HY
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  2:16   ` Hongyi Zhao
@ 2021-07-05  3:48     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05  4:31       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05  5:06     ` Jean Louis
  1 sibling, 1 reply; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05  3:48 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> On Mon, Jul 5, 2021 at 12:19 AM Emanuel Berg via Users list for the
> GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
>>
>> Hongyi Zhao wrote:
>>
>> > I've noticed there are some similar functions, i.e., append,
>> > push, and add-to-list, for revising/updating the content of
>> > a list. But I'm still not so clear on the specific use
>> > scenarios for them. Consider the following command [1]
>>
>> `nconc', `cl-pushnew', (setq lst `(,@lst el)) ...
>
> Does the following append `el' to `lst'?
>
> (setq lst `(,@lst el))

Yes, literally, but maybe it makes more sense if that is
evaluated as well?

(defvar lst)
(setq lst '(a b c))

(defvar el)
(setq el 4)

(setq lst `(,@lst ,el))

Now "lst" will be (a b c 4)

> This is one of the reasons that baffles me the most - there
> are so many functions in Emacs.

The more the merrier...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  3:48     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05  4:31       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05  5:07         ` Hongyi Zhao
  0 siblings, 1 reply; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05  4:31 UTC (permalink / raw)
  To: help-gnu-emacs

>> Does the following append `el' to `lst'?
>>
>> (setq lst `(,@lst el))
>
> Yes, literally, but maybe it makes more sense if that is
> evaluated as well?
>
> (defvar lst)
> (setq lst '(a b c))
>
> (defvar el)
> (setq el 4)
>
> (setq lst `(,@lst ,el))
>
> Now "lst" will be (a b c 4)

(setq lst '(a b))
(setq lst `(,@lst logic) ; (a b logic)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  2:16   ` Hongyi Zhao
  2021-07-05  3:48     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05  5:06     ` Jean Louis
  2021-07-05  6:22       ` Hongyi Zhao
  1 sibling, 1 reply; 38+ messages in thread
From: Jean Louis @ 2021-07-05  5:06 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs, Emanuel Berg

* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-05 05:17]:
> On Mon, Jul 5, 2021 at 12:19 AM Emanuel Berg via Users list for the
> GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> >
> > Hongyi Zhao wrote:
> >
> > > I've noticed there are some similar functions, i.e., append,
> > > push, and add-to-list, for revising/updating the content of
> > > a list. But I'm still not so clear on the specific use
> > > scenarios for them. Consider the following command [1]
> >
> > `nconc', `cl-pushnew', (setq lst `(,@lst el)) ...
> 
> Does the following append `el' to `lst'?
> 

(defvar lst '()) ⇒ lst

(setq lst `(,@lst el)) ⇒ (el)

lst  ⇒ (el)

I see it does when variable `list' is defined in advance.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  4:31       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05  5:07         ` Hongyi Zhao
  2021-07-05  5:50           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-05  5:07 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Mon, Jul 5, 2021 at 12:32 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> >> Does the following append `el' to `lst'?
> >>
> >> (setq lst `(,@lst el))
> >
> > Yes, literally, but maybe it makes more sense if that is
> > evaluated as well?
> >
> > (defvar lst)
> > (setq lst '(a b c))
> >
> > (defvar el)
> > (setq el 4)
> >
> > (setq lst `(,@lst ,el))
> >
> > Now "lst" will be (a b c 4)
>
> (setq lst '(a b))
> (setq lst `(,@lst logic) ; (a b logic)
>

You have a typo here, should be the following:

((setq lst `(,@lst logic))

Wonderful examples, but how to eval multiple line lisp codes in
scratch buffer? I only know with twice hitting of `C-j' for this job,
as shown below:

(setq lst '(a b)) <--- C-j
(a b)

((setq lst `(,@lst logic)) <-- C-j
(a b logic)

HY
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  5:07         ` Hongyi Zhao
@ 2021-07-05  5:50           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05  6:19             ` Hongyi Zhao
  0 siblings, 1 reply; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05  5:50 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

>> (setq lst '(a b))
>> (setq lst `(,@lst logic) ; (a b logic)
>
> You have a typo here, should be the following:
>
> ((setq lst `(,@lst logic))

Heh, yes but now there is another typo :)

It should look like this:

  (setq lst '(a b))
  (setq lst `(,@lst logic)) ; (a b logic)

> Wonderful examples, but how to eval multiple line lisp codes
> in scratch buffer? I only know with twice hitting of `C-j'
> for this job, as shown below:

You can use `eval-buffer' or enclose it in a `progn' perhaps.
Or, for this particular example, `let'/`let*'...

I have M-9 do `eval-last-sexp', more ergonomic IMO than
whatever is the default binding...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  5:50           ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05  6:19             ` Hongyi Zhao
  0 siblings, 0 replies; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-05  6:19 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Mon, Jul 5, 2021 at 1:51 PM Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> >> (setq lst '(a b))
> >> (setq lst `(,@lst logic) ; (a b logic)
> >
> > You have a typo here, should be the following:
> >
> > ((setq lst `(,@lst logic))
>
> Heh, yes but now there is another typo :)
>
> It should look like this:
>
>   (setq lst '(a b))
>   (setq lst `(,@lst logic)) ; (a b logic)
>

Yes. Thanks again.

> > Wonderful examples, but how to eval multiple line lisp codes
> > in scratch buffer? I only know with twice hitting of `C-j'
> > for this job, as shown below:
>
> You can use `eval-buffer'

I tried with `eval-buffer' but can't see the expected output.

> or enclose it in a `progn' perhaps.
> Or, for this particular example, `let'/`let*'...
>
> I have M-9 do `eval-last-sexp', more ergonomic IMO than
> whatever is the default binding...
>

HY
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  5:06     ` Jean Louis
@ 2021-07-05  6:22       ` Hongyi Zhao
  2021-07-05  6:32         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 38+ messages in thread
From: Hongyi Zhao @ 2021-07-05  6:22 UTC (permalink / raw)
  To: Hongyi Zhao, Emanuel Berg, help-gnu-emacs

On Mon, Jul 5, 2021 at 1:11 PM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-05 05:17]:
> > On Mon, Jul 5, 2021 at 12:19 AM Emanuel Berg via Users list for the
> > GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> > >
> > > Hongyi Zhao wrote:
> > >
> > > > I've noticed there are some similar functions, i.e., append,
> > > > push, and add-to-list, for revising/updating the content of
> > > > a list. But I'm still not so clear on the specific use
> > > > scenarios for them. Consider the following command [1]
> > >
> > > `nconc', `cl-pushnew', (setq lst `(,@lst el)) ...
> >
> > Does the following append `el' to `lst'?
> >
>
> (defvar lst '()) ⇒ lst
>

(equal '() nil)
t

So, I would rather write it like this:

(defvar lst nil)

HY

> (setq lst `(,@lst el)) ⇒ (el)
>
> lst  ⇒ (el)
>
> I see it does when variable `list' is defined in advance.
>
> --
> Jean
>
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
>
> In support of Richard M. Stallman
> https://stallmansupport.org/



-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05  6:22       ` Hongyi Zhao
@ 2021-07-05  6:32         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05  6:32 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> (equal '() nil)
> t
>
> So, I would rather write it like this:
>
> (defvar lst nil)

But with '() you see that it is (an empty) list:

  (defvar lst)
  (setq lst '())

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
@ 2021-07-05 14:37 Drew Adams
  2021-07-05 14:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 38+ messages in thread
From: Drew Adams @ 2021-07-05 14:37 UTC (permalink / raw)
  To: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'; +Cc: Emanuel Berg

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

> But with '() you see that it is (an empty) list:
> 
>   (defvar lst)
>   (setq lst '())

Yes, for human reading, () suggests that the
value might be used as a list, and nil suggests
that it might not be (e.g., it might be used as
a truth value or otherwise).

But there is no reason to quote ().  Like t,
() is evaluates to itself.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 12379 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 14:37 Drew Adams
@ 2021-07-05 14:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 15:19   ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-05 15:41   ` tomas
  0 siblings, 2 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05 14:53 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>> But with '() you see that it is (an empty) list:
>> 
>>   (defvar lst)
>>   (setq lst '())
>
> Yes, for human reading, () suggests that the value might be
> used as a list, and nil suggests that it might not be (e.g.,
> it might be used as a truth value or otherwise).
>
> But there is no reason to quote (). Like t, () is evaluates
> to itself.

Yes, there is a reason, it feels natural because of the way of
creating lists like this '(raz dva tri)

An unquoted list would be, for example, (list 1 2 3) So to
keep it consistent, without a quote, would it be

  (defvar lst)
  (setq lst (list)) ; nil

?

Is it just me, or does Lisp have so many
parenthesis everywhere? '() makes it easier to spot
immediately, hey, that's an empty list.

But ... ultimately one writes code so the computer can execute
it, and not so that a human can read it. So maybe one
shouldn't quote empty lists?

If so, I have 14 corrections to make...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 14:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05 15:19   ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-05 16:46     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 15:41   ` tomas
  1 sibling, 1 reply; 38+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-05 15:19 UTC (permalink / raw)
  To: help-gnu-emacs

> But ... ultimately one writes code so the computer can execute
> it, and not so that a human can read it.  So maybe one
> shouldn't quote empty lists?

You should quote () when you feel like it, and you should not quote it
when you don't feel like it.

Note that this only applies when you originally write the code.  If your
feeling about it changes, that is not a blank check to allow you to
gratuitously change the code to adjust it to your whims.


        Stefan




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 14:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 15:19   ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-05 15:41   ` tomas
  2021-07-05 16:58     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 38+ messages in thread
From: tomas @ 2021-07-05 15:41 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

On Mon, Jul 05, 2021 at 04:53:44PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:

[...]

> But ... ultimately one writes code so the computer can execute
> it, and not so that a human can read it. So maybe one
> shouldn't quote empty lists?

There's at least one wise person who put that exactly the other
way around:

  "Programming is the art of telling another human being
   what one wants the computer to do"

   -- D.E.Knuth [1]

Cheers

[1] https://cacm.acm.org/magazines/2012/4/147340-reading-cs-classics/fulltext

 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 15:19   ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-05 16:46     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-06 19:54       ` Jean Louis
  0 siblings, 1 reply; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05 16:46 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier via Users list for the GNU Emacs text editor wrote:

> You should quote () when you feel like it, and you should
> not quote it when you don't feel like it.
>
> Note that this only applies when you originally write the
> code. If your feeling about it changes, that is not a blank
> check to allow you to gratuitously change the code to adjust
> it to your whims.

Oh, no!

But I don't remember if I knew () was possible when I wrote
that. Later I saw it in Common Lisp and then I thought, cool,
here you don't need it, now I learn you don't need it Elisp
either...

Wasn't there a civil war in Imperial Russia and the reason was
in what order you'd touch your chest when doing the cross
sign?

They were also taking their programming seriously!

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 15:41   ` tomas
@ 2021-07-05 16:58     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 17:21       ` tomas
                         ` (3 more replies)
  0 siblings, 4 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05 16:58 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

>> But ... ultimately one writes code so the computer can
>> execute it, and not so that a human can read it. So maybe
>> one shouldn't quote empty lists?
>
> There's at least one wise person who put that exactly the
> other way around:
>
>   Programming is the art of telling another human being what
>   one wants the computer to do
>   -- D E Knuth

LaTeX, veeery understandable! Especially when explained to
other humans!

Well, maybe TeX was better in this sense?

We should have a new bible on Computer Science BTW, but this
time in a list format, containing every science/engineering
term including a definition _and_ a minimal example, why not
in Lisp. Then we could just say to every new CS student, "Ah,
so you already know how to program? Good! Now read this book,
and write a mail when you want to do the exam..."

--
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 16:58     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05 17:21       ` tomas
  2021-07-06  1:17         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 18:10       ` Emanuel Berg via Users list for the GNU Emacs text editor
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 38+ messages in thread
From: tomas @ 2021-07-05 17:21 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 704 bytes --]

On Mon, Jul 05, 2021 at 06:58:45PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> tomas wrote:
> 
> >> But ... ultimately one writes code so the computer can
> >> execute it, and not so that a human can read it. So maybe
> >> one shouldn't quote empty lists?
> >
> > There's at least one wise person who put that exactly the
> > other way around:
> >
> >   Programming is the art of telling another human being what
> >   one wants the computer to do
> >   -- D E Knuth
> 
> LaTeX, veeery understandable! Especially when explained to
> other humans!
> 
> Well, maybe TeX was better in this sense?

http://www.catb.org/jargon/html/koans.html

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 16:58     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 17:21       ` tomas
@ 2021-07-05 18:10       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 18:18         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 18:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-06 19:56       ` Jean Louis
  3 siblings, 1 reply; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05 18:10 UTC (permalink / raw)
  To: help-gnu-emacs

I think I'll change them to `(,@())

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 16:58     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 17:21       ` tomas
  2021-07-05 18:10       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05 18:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 18:39         ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-06 19:57         ` Jean Louis
  2021-07-06 19:56       ` Jean Louis
  3 siblings, 2 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05 18:11 UTC (permalink / raw)
  To: help-gnu-emacs

Or `(,@(list))

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 18:10       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05 18:18         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05 18:18 UTC (permalink / raw)
  To: help-gnu-emacs

> I think I'll change them to `(,@())

Backquote is a Lisp macro tho.

Love the docstring BTW: [I fixed the align for the purpose of
this message]

  [...]
  For example:

  b          => (ba bb bc)       ; assume b has this value
  `(a b c)   => (a b c)          ; backquote acts like quote
  `(a ,b c)  => (a (ba bb bc) c) ; insert the value of b
  `(a ,@b c) => (a ba bb bc c)	; splice in the value of b

"For example" - isn't that exactly, and all, it does?

OK, well, ,b can be _evaluated_ as well, not just inserted as
a value, I guess, that's what they mean?

  `(1 2 ,(format "%s %s!" "Sail" "Ho") 4) => (1 2 "Sail Ho!" 4)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 18:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-05 18:39         ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-05 20:35           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-06 19:57         ` Jean Louis
  1 sibling, 1 reply; 38+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-05 18:39 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg [2021-07-05 20:11:59] wrote:
> Or `(,@(list))

A bit too obvious, methinks.  Maybe:

    (seq-intersection (seq-filter #'cl-oddp
                                  (seq-map-indexed
                                   (lambda (_ i) i)
                                   (make-list (random 42) nil)))
                      (seq-filter #'cl-evenp
                                  (seq-map-indexed
                                   (lambda (_ i) i)
                                   (make-list (random 42) nil))))


-- Stefan




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 18:39         ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-05 20:35           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-05 20:35 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier via Users list for the GNU Emacs text editor wrote:

> A bit too obvious, methinks.  Maybe:
>
>     (seq-intersection (seq-filter #'cl-oddp
>                                   (seq-map-indexed
>                                    (lambda (_ i) i)
>                                    (make-list (random 42) nil)))
>                       (seq-filter #'cl-evenp
>                                   (seq-map-indexed
>                                    (lambda (_ i) i)
>                                    (make-list (random 42) nil))))

(nth integer-width
  (string-to-list "Only this message denotes the empty list"))

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 17:21       ` tomas
@ 2021-07-06  1:17         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-06  1:17 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

>> Well, maybe TeX was better in this sense?
>
> http://www.catb.org/jargon/html/koans.html

This reminds me of one time when I went to
Computer School (CS).

A couple of hundred meters from the school building was an
industrial pit, down there one could see flames every hour of
the day - it was part of the commune's system for disposing
of garbage, possibly.

Anyway one time a group of students including me, 12 in total,
went to see the professor who had walked to this place.
When we got close, he asked, "what is it that you want to hear
from my mouth, that you cannot hear from your own?" To this,
all students started to talk at once so not a single word was
heard. The professor said, "you are too many heads for one
body", and pushed 11 students into the flames.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 16:46     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-06 19:54       ` Jean Louis
  2021-07-06 20:08         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 38+ messages in thread
From: Jean Louis @ 2021-07-06 19:54 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-07-05 19:47]:
> But I don't remember if I knew () was possible when I wrote
> that. Later I saw it in Common Lisp and then I thought, cool,
> here you don't need it, now I learn you don't need it Elisp
> either...

I have taken the Lisp manual and started doing something like:

(defun my-fun nil
  (do something))

and I got a digital slap on my finger on the mailing list as I have
not used '() instead of nil.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 16:58     ` Emanuel Berg via Users list for the GNU Emacs text editor
                         ` (2 preceding siblings ...)
  2021-07-05 18:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-06 19:56       ` Jean Louis
  2021-07-06 20:15         ` Emanuel Berg via Users list for the GNU Emacs text editor
  3 siblings, 1 reply; 38+ messages in thread
From: Jean Louis @ 2021-07-06 19:56 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-07-05 20:00]:
> tomas wrote:
> 
> >> But ... ultimately one writes code so the computer can
> >> execute it, and not so that a human can read it. So maybe
> >> one shouldn't quote empty lists?
> >
> > There's at least one wise person who put that exactly the
> > other way around:
> >
> >   Programming is the art of telling another human being what
> >   one wants the computer to do
> >   -- D E Knuth
> 
> LaTeX, veeery understandable! Especially when explained to
> other humans!
> 
> Well, maybe TeX was better in this sense?

LaTeX has a special audience, like typesetters (if it is write English
word) and writers. For them is understandable. Beside the heading
settings, I can write LaTeX natively without problem.

TeX is actually easier to learn.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-05 18:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-05 18:39         ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-06 19:57         ` Jean Louis
  2021-07-06 20:16           ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 38+ messages in thread
From: Jean Louis @ 2021-07-06 19:57 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-07-05 21:16]:
> Or `(,@(list))

That one is so much easier to spot.

From now on:

(defun my-fun `(,@(list))
  (do something))


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-06 19:54       ` Jean Louis
@ 2021-07-06 20:08         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-06 20:08 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> I have taken the Lisp manual and started doing something
> like:
>
> (defun my-fun nil
>   (do something))
>
> and I got a digital slap on my finger on the mailing list as
> I have not used '() instead of nil.

Yeah, it should look like this

  (defun my-f ()
    (do-something) )

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-06 19:56       ` Jean Louis
@ 2021-07-06 20:15         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-06 20:15 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> LaTeX has a special audience, like typesetters (if it is
> write English word) and writers. For them is understandable.
> Beside the heading settings, I can write LaTeX natively
> without problem.

I'd say a general-purpose programming language like Lisp is
ten times easier to explain to anyone compared to the
intricacies of LaTeX, but it also depend on the person, some
people cannot understand programming, and these can't
understand either. I once met a guy who I considered
intelligent enough and I thought I'd draw him a for loop on
a paper, he immediately started to scream in terror about
unrelated things, anything rather than to be put to the test
and fail. Pathetic I guess, but yeah, he just couldn't do it
and he knew it.

Other people can understand a for loop but their minds are so
chaotic while they can understand individual pieces they could
never work on even a small program and hold it to some extent
in their heads at once.

And so on. I didn't believe this was the way, I thought anyone
could learn everything, but after seeing so many people fail at
the above things I now know it isn't so.

> TeX is actually easier to learn.

One would think so.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: append, push, and add-to-list.
  2021-07-06 19:57         ` Jean Louis
@ 2021-07-06 20:16           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 38+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-06 20:16 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> From now on:
>
> (defun my-fun `(,@(list))
>   (do something))

Hahaha, but that doesn't work, `defun' is a Lisp macro...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2021-07-06 20:16 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-04  3:18 append, push, and add-to-list Hongyi Zhao
2021-07-04  4:35 ` Jean Louis
2021-07-04  5:11   ` Hongyi Zhao
2021-07-04 11:28     ` Jean Louis
2021-07-04 13:50       ` Hongyi Zhao
2021-07-04 15:58         ` Jean Louis
2021-07-05  2:04           ` Hongyi Zhao
2021-07-04 16:01         ` [External] : " Drew Adams
2021-07-04 16:20     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-04 16:19 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05  2:16   ` Hongyi Zhao
2021-07-05  3:48     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05  4:31       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05  5:07         ` Hongyi Zhao
2021-07-05  5:50           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05  6:19             ` Hongyi Zhao
2021-07-05  5:06     ` Jean Louis
2021-07-05  6:22       ` Hongyi Zhao
2021-07-05  6:32         ` Emanuel Berg via Users list for the GNU Emacs text editor
  -- strict thread matches above, loose matches on Subject: below --
2021-07-05 14:37 Drew Adams
2021-07-05 14:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05 15:19   ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-05 16:46     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-06 19:54       ` Jean Louis
2021-07-06 20:08         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05 15:41   ` tomas
2021-07-05 16:58     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05 17:21       ` tomas
2021-07-06  1:17         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05 18:10       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05 18:18         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05 18:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-05 18:39         ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-05 20:35           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-06 19:57         ` Jean Louis
2021-07-06 20:16           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-06 19:56       ` Jean Louis
2021-07-06 20:15         ` Emanuel Berg via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.