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

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

Making a list from a list and an array


From: Heime
Subject: Making a list from a list and an array
Date: Sun, 06 Nov 2022 16:40:10 +0000

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






reply via email to

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