如何格式化字符串列表

ton*_*day 5 lisp elisp

我有一个字符串列表,我需要使用emacs lisp格式化.这是我能想到的唯一方法:

(setq slist '("is there" "any" "way" "directed iteration"))    
(format "%s _%s_ %s to do %S in elisp?" 
        (elt slist 0)
        (elt slist 1)
        (elt slist 2)
        (elt slist 3)
        (elt slist 4))
Run Code Online (Sandbox Code Playgroud)

给我我想要的东西.

is there _any_ way to do "directed iteration" in elisp?
Run Code Online (Sandbox Code Playgroud)

必须有一种更优雅的方式,但经过深思熟虑,我没有看到它.我是emacs lisp的新手,我可能会遗漏一些明显的东西.

Vat*_*ine 6

使用apply

(apply 'format "%s _%s_ %s to do %S in elisp?" slist)
Run Code Online (Sandbox Code Playgroud)

apply函数将一个函数(或符号)作为其第一个参数,然后是许多单独的参数,最后是一个参数列表。