“application: not a procedure” in binary arithmetic procedures

浪子不回头ぞ 提交于 2019-11-26 11:25:48

In this line, you're calling multBins with (cons 0 x) and (rest y), and getting some result r, and then trying to call r:

((= (first y) 0) ((multBins (cons 0 x) (rest y))))
;                ^                              ^
;                +--- function application -----+

The same kind of thing is happening in the next line, where you're calling addWithCarry with some arguments, getting a result r, and trying to call r:

(#t              ((addWithCarry x (multBins (cons 0 x) (rest y)) 0)))))
;                ^                                                 ^
;                +-------------- function application -------------+

Presumable the unapplicable value '(0 0 0 1 0 1 1) is being returned by one of these.

In a very simplified case, consider this transcript from the 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]

You didn't mention what editor/IDE/debugger you're using, but some should have made this a bit easier to spot. For instance, when I load your code (minus the call to test, whose definition I don't have, and with definitions of first and rest), DrRacket highlights the location of the offending call:

While both of the problematic calls that I've pointed out need to be fixed, the error that you're seeing right now is occurring in the second of the two.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!