0
嗨,大家好我想要連接一個列表並返回第一個值與額外的括號,例如當我調用函數(bracket-head '(a b c)) => ((A) B C).
我已經完成它給我的結果,當我打電話給功能與'('(a) b c)
。因此,這裏是我的代碼:添加額外支架到列表中的參數
(defun bracket-head (list)
(append (first list) (rest list))
嗨,大家好我想要連接一個列表並返回第一個值與額外的括號,例如當我調用函數(bracket-head '(a b c)) => ((A) B C).
我已經完成它給我的結果,當我打電話給功能與'('(a) b c)
。因此,這裏是我的代碼:添加額外支架到列表中的參數
(defun bracket-head (list)
(append (first list) (rest list))
首先,()
是括號,括號沒有。
接下來,「額外的括號」意味着你包裹中的對象的列表:
[5]> (list 1)
(1)
[6]> (list *)
((1))
[7]> (list *)
(((1)))
[8]> (list *)
((((1))))
[9]> (list *)
(((((1)))))
因此,你需要做的是
[13]> (defparameter list (list 1 2 3))
LIST
[14]> (setf (first list) (list (first list)))
(1)
[15]> list
((1) 2 3)
或者,如果你不想修改該列表就地:
[17]> (defparameter list (list 1 2 3))
LIST
[18]> (cons (list (first list)) (rest list))
((1) 2 3)
[19]> list
(1 2 3)