1 回答

TA貢獻1829條經驗 獲得超9個贊
在這一行中,您multBins使用(cons 0 x)和進行調用(rest y),并得到一些結果r,然后嘗試調用r:
((= (first y) 0) ((multBins (cons 0 x) (rest y))))
; ^ ^
; +--- function application -----+
在下一行中,您正在addWithCarry使用一些參數進行調用,獲取結果r并嘗試調用r:
(#t ((addWithCarry x (multBins (cons 0 x) (rest y)) 0)))))
; ^ ^
; +-------------- function application -------------+
可能'(0 0 0 1 0 1 1)是其中之一返回了不適用的值。
在非常簡化的情況下,請考慮DrRacket REPL的以下記錄:
> (define (value) ; a function that returns the
'(0 0 0 1 0 1 1)) ; same value that yours should
> (value) ; calling it produces the value
(0 0 0 1 0 1 1)
> ((value)) ; calling it and then calling
; return value causes the same
; error that you're seeing
; application: not a procedure;
; expected a procedure that can be applied to arguments
; given: (0 0 0 1 0 1 1)
; arguments...: [none]
您沒有提到您使用的是什么編輯器/ IDE /調試器,但是其中一些應該使它更容易發現。例如,當我打開你的代碼(減去調用test,其定義我沒有,用的定義first和rest),DrRacket凸顯違規調用的位置:
雖然我已經指出了兩個有問題的調用,但都需要修復,但是您現在看到的錯誤是在這兩個中的第二個發生。
- 1 回答
- 0 關注
- 397 瀏覽
添加回答
舉報