unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Using list with append
@ 2022-11-09 12:09 Heime
  2022-11-09 15:26 ` Emanuel Berg
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Heime @ 2022-11-09 12:09 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


This function makes a list of lists.

(defun pmchart selectr nc)
  "TODO."
  
  (seq-mapn
     (lambda (p q)
       (message "p: %S" p)
       (list q (append (make-list p "xxxxx")
               (make-list (- nc 1 p) ""))))
       selectr
       descr))

Calling

(pmchart '("Peter" "Paul") [3 2] 5)

gives the list

'(("Peter" ("xxxxx" "xxxxx" "xxxxx" "")) 
  ("Paul" ("xxxxx" "xxxxx" "" "")))

But I want to adapt it to get this

'(("Peter" "xxxxx" "xxxxx" "xxxxx" "") 
  ("Paul" "xxxxx" "xxxxx" "" ""))

Doing the following did not help

(list (append q (make-list p "xxxxx") (make-list (- nc 1 p) ""))))





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

* Re: Using list with append
  2022-11-09 12:09 Using list with append Heime
@ 2022-11-09 15:26 ` Emanuel Berg
  2022-11-09 15:54 ` [External] : " Drew Adams
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Emanuel Berg @ 2022-11-09 15:26 UTC (permalink / raw)
  To: help-gnu-emacs

Heime wrote:

> (defun pmchart selectr nc)

Function names: use-normal-language

Argument names: short forms that are obvious encouraged, e.g.
cmd, len, lang, beg, end, src, dst, and so on, otherwise use
normal language there as well

> "TODO."

Remove, it's better not to have a docstring than to have one
that doesn't document anything, (checkdoc-current-buffer t)
will also tell you that one is formally incorrect.

> (pmchart '("Peter" "Paul") [3 2] 5)
>
> gives the list
>
> '(("Peter" ("xxxxx" "xxxxx" "xxxxx" "")) 
>   ("Paul" ("xxxxx" "xxxxx" "" "")))

If the list of X-Strings are associated with the names, it is
better to have a function that does one such item, so that
would be called like this, probably

  (x-name-item "Peter" 3 5)

then to do the whole table for each line there would be one
such call.

So the semantics of what you are doing is implemented
in/enforced by the code that actually does the work, as well,
if you will ...

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




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

* RE: [External] : Using list with append
  2022-11-09 12:09 Using list with append Heime
  2022-11-09 15:26 ` Emanuel Berg
@ 2022-11-09 15:54 ` Drew Adams
  2022-11-10 18:02   ` Emanuel Berg
  2022-11-09 17:08 ` Stephen Berman
  2022-11-10 14:21 ` Jean Louis
  3 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2022-11-09 15:54 UTC (permalink / raw)
  To: Heime, Heime via Users list for the GNU Emacs text editor
  Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

A general suggestion:

Google/DuckDuckGo/<whatever> for
"learning lisp" or "lisp tutorial".

Just learn the basics, to start with.
Don't bother with trying to incorporate
libraries, use seq.el, etc.  Just get
the standard, age-old, basic Lisp under
your belt.

Those basics will help you regardless
of whatever other code you might later
want to use as a shortcut or because
you find it more elegant (or someone
tells you it's better).

Do this and you won't find yourself so
dependent on a zillion seemingly one-off,
independent questions.

 - Just one opinion/suggestion.




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

* Re: Using list with append
  2022-11-09 12:09 Using list with append Heime
  2022-11-09 15:26 ` Emanuel Berg
  2022-11-09 15:54 ` [External] : " Drew Adams
@ 2022-11-09 17:08 ` Stephen Berman
  2022-11-09 17:19   ` Heime
  2022-11-10 14:21 ` Jean Louis
  3 siblings, 1 reply; 7+ messages in thread
From: Stephen Berman @ 2022-11-09 17:08 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Wed, 09 Nov 2022 12:09:04 +0000 Heime <heimeborgia@protonmail.com> wrote:

> This function makes a list of lists.
>
> (defun pmchart selectr nc)

I assume you meant this: (defun pmchart (descr selectr nc)

>   "TODO."
>
>   (seq-mapn
>      (lambda (p q)
>        (message "p: %S" p)
>        (list q (append (make-list p "xxxxx")
>                (make-list (- nc 1 p) ""))))
>        selectr
>        descr))
>
> Calling
>
> (pmchart '("Peter" "Paul") [3 2] 5)
>
> gives the list
>
> '(("Peter" ("xxxxx" "xxxxx" "xxxxx" ""))
>   ("Paul" ("xxxxx" "xxxxx" "" "")))
>
> But I want to adapt it to get this
>
> '(("Peter" "xxxxx" "xxxxx" "xxxxx" "")
>   ("Paul" "xxxxx" "xxxxx" "" ""))
>
> Doing the following did not help
>
> (list (append q (make-list p "xxxxx") (make-list (- nc 1 p) ""))))

You want to append the list of x's to the list containing the name, not
to the name (which is a sequence of characters, so appending to it would
make a list beginning with the numerical values of the characters of the
name):

(append (list q) (make-list p "xxxxx") (make-list (- nc 1 p) ""))

Steve Berman



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

* Re: Using list with append
  2022-11-09 17:08 ` Stephen Berman
@ 2022-11-09 17:19   ` Heime
  0 siblings, 0 replies; 7+ messages in thread
From: Heime @ 2022-11-09 17:19 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Wednesday, November 9th, 2022 at 5:08 PM, Stephen Berman <stephen.berman@gmx.net> wrote:


> On Wed, 09 Nov 2022 12:09:04 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > This function makes a list of lists.
> > 
> > (defun pmchart selectr nc)
> 
> 
> I assume you meant this: (defun pmchart (descr selectr nc)
> 
> > "TODO."
> > 
> > (seq-mapn
> > (lambda (p q)
> > (message "p: %S" p)
> > (list q (append (make-list p "xxxxx")
> > (make-list (- nc 1 p) ""))))
> > selectr
> > descr))
> > 
> > Calling
> > 
> > (pmchart '("Peter" "Paul") [3 2] 5)
> > 
> > gives the list
> > 
> > '(("Peter" ("xxxxx" "xxxxx" "xxxxx" ""))
> > ("Paul" ("xxxxx" "xxxxx" "" "")))
> > 
> > But I want to adapt it to get this
> > 
> > '(("Peter" "xxxxx" "xxxxx" "xxxxx" "")
> > ("Paul" "xxxxx" "xxxxx" "" ""))
> > 
> > Doing the following did not help
> > 
> > (list (append q (make-list p "xxxxx") (make-list (- nc 1 p) ""))))
> 
> 
> You want to append the list of x's to the list containing the name, not
> to the name (which is a sequence of characters, so appending to it would
> make a list beginning with the numerical values of the characters of the
> name):
> 
> (append (list q) (make-list p "xxxxx") (make-list (- nc 1 p) ""))
> 
> Steve Berman

You are absolutely right.  Thank you so very much.




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

* Re: Using list with append
  2022-11-09 12:09 Using list with append Heime
                   ` (2 preceding siblings ...)
  2022-11-09 17:08 ` Stephen Berman
@ 2022-11-10 14:21 ` Jean Louis
  3 siblings, 0 replies; 7+ messages in thread
From: Jean Louis @ 2022-11-10 14:21 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-11-09 15:11]:
> 
> This function makes a list of lists.
> 
>

I see function below is not correct, so I do not know how you got it to work:

;; (defun pmchart selectr nc)
;;   "TODO."
;;   (seq-mapn
;;      (lambda (p q)
;;        (message "p: %S" p)
;;        (list q (append (make-list p "xxxxx")
;;                (make-list (- nc 1 p) ""))))
;;        selectr
;;        descr)

As it should be formatted this way:

(defun pmchart (selectr nc)
  "TODO."
  (seq-mapn
     (lambda (p q)
       (message "p: %S" p)
       (list q (append (make-list p "xxxxx")
               (make-list (- nc 1 p) ""))))
       selectr
       descr))

> Calling

The function below is wrong, you are providing 3 arguments, but expecting 2:

> (pmchart '("Peter" "Paul") [3 2] 5)

So I do not know how you make it work. Please provide first workable function:

gives the list

;; '(("Peter" ("xxxxx" "xxxxx" "xxxxx" "")) 
;;   ("Paul" ("xxxxx" "xxxxx" "" "")))

;; But I want to adapt it to get this

;; '(("Peter" "xxxxx" "xxxxx" "xxxxx" "") 
;;   ("Paul" "xxxxx" "xxxxx" "" ""))

"Peter" shall be 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] 7+ messages in thread

* Re: [External] : Using list with append
  2022-11-09 15:54 ` [External] : " Drew Adams
@ 2022-11-10 18:02   ` Emanuel Berg
  0 siblings, 0 replies; 7+ messages in thread
From: Emanuel Berg @ 2022-11-10 18:02 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

> Google/DuckDuckGo/<whatever> for "learning lisp" or "lisp
> tutorial".

Isn't such stuff shipped with Emacs?

Along with an interactive mode and rehearse questions
and stuff?

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




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

end of thread, other threads:[~2022-11-10 18:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-09 12:09 Using list with append Heime
2022-11-09 15:26 ` Emanuel Berg
2022-11-09 15:54 ` [External] : " Drew Adams
2022-11-10 18:02   ` Emanuel Berg
2022-11-09 17:08 ` Stephen Berman
2022-11-09 17:19   ` Heime
2022-11-10 14:21 ` Jean Louis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).