【问题标题】:Is there a single function that concat a string to every entry in a list?是否有一个函数可以将字符串连接到列表中的每个条目?
【发布时间】:2016-02-23 09:00:01
【问题描述】:
(setq a '("bar" "baz" "barz"))
(setq prefix "foo")

;; Expected result
==> ("foobar" "foobaz" "foobarz")

我一直在通过dolist 或迭代car 来执行此操作。是否有一个函数在做同样的工作?

【问题讨论】:

    标签: string list emacs elisp


    【解决方案1】:

    不是单个函数,但我会使用:

    (mapcar (apply-partially #'concat prefix) a)
    

    不过,有很多方法可以做到这一点,而且你所做的可能没有什么特别的问题。

    【讨论】:

      猜你喜欢
      • 2021-10-17
      • 2011-09-20
      • 2016-12-15
      • 2017-07-24
      • 2021-04-23
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多