unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Passing two sequences to  make a list of lists
Date: Tue, 08 Nov 2022 06:22:16 +0000	[thread overview]
Message-ID: <4oPQf3c2ECktS6pjTAjFaazCdaSiv-o5UokSLuAgiK7rJR-x7fwQnh-zFXKVnxrywei4kiHIwzXQNC92xggBzzKbnYeLPEQMeAQNnlQn8ro=@protonmail.com> (raw)



I have constructed the following to make a lists of lists.  The purpose
is to have a list DESCR of N string elements; and an associated array SELECTR,
also of N elements but composed of integers.

The output would be a list of lists.  Each internal list would represent
a row in a table.  The separate rows (each a list) are then put in a list.

Each element of DESCR would be used as the first element of each list.
Whilst the corresponding DESCR value would be the number of "xxxxx" blocks
in the remaining elements of each list, with the rest being empty strings.   

I would also require a numeric value that determines the total number of elements 
in each list, call it M.

Thus for DESCR being '("Peter" "Paul"); and SELECTR being [3 2]; and M being 5; one
would get

'(("Peter" "xxxxx" "xxxxx" "xxxxx" "")  ; list of M of 5 elements
  (Paul"   "xxxxx" "xxxxx" "" ""))      ; number of "xxxxx" blacks being 2


This is the function I have been playing with


  (seq-mapn
     (lambda (x y)
       (list x (mapconcat
		  (lambda (s)
		    (prog1
			(if (> y 0) (append (make-list s "xxxxx")) "")
                      (setq y (1- y))))
                  "")
             " "))
     descr
     selectr)



             reply	other threads:[~2022-11-08  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08  6:22 Heime [this message]
2022-11-08  6:40 ` Passing two sequences to make a list of lists Emanuel Berg
2022-11-08 13:37   ` Heime

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='4oPQf3c2ECktS6pjTAjFaazCdaSiv-o5UokSLuAgiK7rJR-x7fwQnh-zFXKVnxrywei4kiHIwzXQNC92xggBzzKbnYeLPEQMeAQNnlQn8ro=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).