What's the canonical way to join strings in a list?

前端 未结 6 1928
慢半拍i
慢半拍i 2020-12-03 01:12

I want to convert (\"USERID=XYZ\" \"USERPWD=123\") to \"USERID=XYZ&USERPWD=123\". I tried

(apply #\'concatenate \'string \'(\"         


        
6条回答
  •  借酒劲吻你
    2020-12-03 01:45

    A bit late to the party, but reduce works fine:

    (reduce (lambda (acc x)
              (if (zerop (length acc))
                  x
                  (concatenate 'string acc "&" x)))
            (list "name=slappy" "friends=none" "eats=dogpoo")
            :initial-value "")
    

提交回复
热议问题