0
當前列表中刪除第一個值我正在使我的自定義對象作爲參數的函數,然後從該對象中的列表中獲取第一個參數,將其返回並從對象中刪除它。代碼是:從計劃
(define (make-source sequence . xs)
(let ((a (if (not (null? xs))
xs
(list #f))))
(cond ((string? sequence) (append (string->list sequence) (list a)))
((vector? sequence) (append (vector->list sequence) (list a)))
(else (append sequence (list a))))))
(define (next src)
(if (equal? (car src) '(#f))
#t
(let ((a (car src)))
(set! src (make-source (cdr src)))
a)))
問題是next
返回值而不更改對象。 你能幫我解決問題嗎? 另外,是否有可能從該列表中刪除元素而不創建新的函數?