Re: Storing values separately for cl-loop

Heime <[email protected]> Fri, 10 Jul 2026 14:24:00 +0000
Newsgroups gmane.emacs.help
Message-ID <ObJAYE0Y-wz4dbDpCMLwxHtL7-J09a23-rDe4L2COrfTmdKiNpzH8cdeFMx599jO2KqsHEZFgcjVag98Lkjf4C_q2PD89RgIDEwnwmw0FbM=@protonmail.com>
On Saturday, July 11th, 2026 at 12:34 AM, tpeplt <[email protected]> wrote:

> Heime <[email protected]> writes:
> 
> > How can I store the result of (format "%s %s%d%s%s" prefix "<" i ">" tag)
> > separately for cl-loop?
> >
> >       (let ( (prefix  (if (= (length comment-start) 1)
> >                           ;; Single character comment start
> > 	                  (make-string 3 (string-to-char comment-start))
> >                         ;; Multiple character comment start
> >                         comment-start))
> > 	     (tag     (if tag (format "%s" tag) "")) )
> >         (cl-loop for i from 1 to n
> >                    collect (cons (format "%s %s%d%s%s" prefix "<" i ">" tag)
> >                                  i)))
> >
> 
> Can you describe or provide an example of the output of
> ‘cl-loop’ that you are attempting to produce?  It is unclear
> (to me, at least) what you are asking.

I want to have the following line
 collect (cons var i)))
 
where var is constructed previously from (format "%s %s%d%s%s" prefix "<" i ">" tag)

The cl-loop output would be something like '((";;; <1>kc") . 1) (";;; <2>kc") . 2))

> Also, the code that you provided has two problems:
> 
>   1. ‘tag’ is referenced, but it is undefined.  You could
>      provide an example with ‘tag’ replaced by a constant
>      value.
>   2. ‘for i from 1 to n’ references ‘n’, but it is
>      undefined.

n is numeric global variable, whilst tag is some string.
 
> --
> The lyf so short, the craft so long to lerne.
> - Geoffrey Chaucer, The Parliament of Birds.
> 
>