help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passing two sequences to make a list of lists


From: Heime
Subject: Passing two sequences to make a list of lists
Date: Tue, 08 Nov 2022 06:22:16 +0000


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 via email to

[Prev in Thread] Current Thread [Next in Thread]