jeudi 12 mars 2020

clisp: how to remove parenthesis from sublists within a list?

(defun ppl (list)
        (loop for x in list
            collect (cons x '(ppl))
         )
     )

(print(ppl '(1 2 3))) => ((1 ppl) (2 ppl) (3 ppl))

While still inside ppl, how do I remove the parenthesis so that the result becomes

= > (1 ppl 2 ppl 3 ppl) ???

I understand that my code fundamentally creates a list of sublists. Could use some help on flattening out the list. Perhaps if I could in some way get the list that collect returns?

Aucun commentaire:

Enregistrer un commentaire