gpt4 book ai didi

error-handling - 方案:Why am i getting this error -assertion-violation: argument of wrong type [car] (car '())

转载 作者:行者123 更新时间:2023-12-03 09:09:21 26 4
gpt4 key购买 nike

我在计划中的功能是尝试获取省的详细信息:

(define (getProvincesHelper sales provincesList)

(if (null? sales)

provincesList

( getProvincesHelper (cdr sales) (append (list (cadr(cadddr sales))) provincesList))

)
)

(define (getProvinces sales)

(getProvincesHelper sales '())

)

数据列表是这种格式
;(orderNum (orderDate shipDate) (grossSale discount profit unitPrice) (deliveryMethod province) product)

(3 ("10/13/2010" "10/20/2010") (261.54 0.04 -213.25 38.94) ("Regular Air" "Nunavut") "Eldon Base for stackable storage shelf, platinum")

我得到错误:
assertion-violation: argument of wrong type [car]
(car '())

最佳答案

这段代码:

(cadr (cadddr sales))

要求 sales具有足够的结构,以便您不会从非对值中删除 carcdr。这对于名称中的每个a和d都是这样的:
(cadr '(1))

产生相同的错误, cdr有效,但 car上的 '()无效。

关于error-handling - 方案:Why am i getting this error -assertion-violation: argument of wrong type [car] (car '()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46803124/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com