我想在对/元组列表的末尾添加一对/元组。我只是想给它最后一个数字/优先级。
致电
(addItem“奶酪”购物清单)
我想回来:
((“Milk”1)(“Eggs”2)(“Cheese”3))
但我现在回来了:
((“Milk”1)(“Eggs”2)“Cheese”3)
我是Scheme的初学者,我很感激帮助!
(define shopping-list '( ("Milk" 1) ("Eggs" 2)))
(define (addItem k lst)
( let ( [ queue-length (length lst)])
(append lst (list k (+ queue-length 1)))
)
)
(addItem "Cheese" shopping-list)