unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Making a list from a list and an array
@ 2022-11-06 16:40 Heime
  0 siblings, 0 replies; only message in thread
From: Heime @ 2022-11-06 16:40 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


I want to use a list of strings (in descr) to this function so that each element is placed
at the beginning of each list.

Currently 

(listru '("R1" "R2" "R3" "R4" "R5") [3 2 1 1 0]) gives me 

(("xxxxx" "xxxxx" "xxxxx") 
 ("xxxxx" "xxxxx" "") 
 ("xxxxx" "" "") 
 ("xxxxx" "" "") 
 ("" "" ""))

I want to get the following

(("R1" "xxxxx" "xxxxx" "xxxxx") 
 ("R2" "xxxxx" "xxxxx" "") 
 ("R3" "xxxxx" "" "") 
 ("R4" "xxxxx" "" "") 
 ("R5" "" "" ""))

This is the function

(defun listru (descr rekr)
  "DOCSTRING."

  (mapcar
   (lambda (n)
     (append (make-list n "xxxxx")
             (make-list (- 3 n) "")))
   rekr))






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-06 16:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-06 16:40 Making a list from a list and an array Heime

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).