I am using the following function to make a list of lists.

(defun pmchart selectr nc)

     (lambda (p q)
       (message "p: %S" p)
       (list q (append (make-list p "xxxxx")
               (make-list (- nc 1 p) ""))))


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

gives the list

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

But what I would like to get is this

'(("Peter" "xxxxx" "xxxxx" "xxxxx" "") 
  ("Paul" "xxxxx" "xxxxx" "" ""))
  • 3
    This is such a bad question. You’re not even saying what problem you are having, or what you have tried, or anything. You’re just dumping your code and assuming that everyone has read your last 20 bad questions.
    – db48x
    Commented Nov 8, 2022 at 17:37
  • I am finding it very hard to do.
    – Dilna
    Commented Nov 8, 2022 at 22:14
  • I might give up on using seq-mapn.
    – Dilna
    Commented Nov 8, 2022 at 22:24
  • If I had an hour to solve a problem and my life depended on the solution, I would spend the first 55 minutes determining the proper question to ask… for once I know the proper question, I could solve the problem in less than five minutes. — Albert Einstein (source: linkedin.com/pulse/…) Commented Nov 9, 2022 at 7:33
  • In other words, spend more time on phrasing your questions and removing errors from them (What is the relation between table-of-frameworks and pmcharts? Why you pass only 1 argument to seq-mapn? etc...). You might already learn a lot from doing that, and you might get extra insights while trying to explain in detail what you are trying to do and which part you get stuck on. Commented Nov 9, 2022 at 7:43

2 Answers 2


In response to your request...

Instead of adding a make-list in the append, (where otherwise, I would have used simply (list q)), I would simply prepend the 'description' using cons:

(defun pmchart (descr selectr &optional nc)
  (seq-mapn (lambda (d s)
              (cons d (append (make-list s "xxxxx")
                              (make-list (- (or nc 5) 1 s) ""))))

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

Also, as you can see, I would probably make the 'number of columns' optional with a default value (as I guess you will have some default use for this).

  • 1
    If you now compare this answer to the answers here and here, I hope you now conclude that the solution indeed was very simple (and also that the second linked answer, is a complete answer to your original question already). Your solution, to me, suggest that you did not yet 'master' the fundamental functions. Commented Nov 9, 2022 at 20:44
  • I have been playing with cons actually. And have noticed that I can pass a list to cons, and the list will be inserted at the beginning of a list of lists.
    – Dilna
    Commented Nov 9, 2022 at 22:12

To solve the problem I have introduced q by making a list with one element containing q.

(defun pmchart (descr selectr nc)
     (lambda (p q)
       (message "p: %S" p)
       (append (make-list 1 q)
               (make-list p "xxxxx")
               (make-list (- nc 1 p) "")))
  • 1
    Did you read the section(s) I suggested? Commented Nov 9, 2022 at 15:39
  • I do not see reason why the solution would fail.
    – Dilna
    Commented Nov 9, 2022 at 17:53
  • Personally, I prefer elegance and simplicity... but your solution works fine too, of course. Commented Nov 9, 2022 at 19:33
  • Would you share your solution, now that I have solved it?
    – Dilna
    Commented Nov 9, 2022 at 20:15
  • Fine, it is only minimally different, as it is also based on the solution here of course... Commented Nov 9, 2022 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.