1
我是新來的球拍。我試圖做的實驗室工作,但...應用程序:不是一個程序方案
#lang scheme
(define lab2
(lambda (currentList counter result)
((let countdown ((i (- (length currentList) 1)))
(if (= i 0) (display result)
(begin
(if (pair? (list-ref currentList i)) ;1 if element is list
(if (> (+ 1 counter) result) ;1 if counter > currentResult
((set! counter (+ 1 counter)) (set! result (+ 1 result)) (countdown(- i 1))) ;2 then counter++, result++
((set! counter (+ 1 counter)) (countdown(- i 1)))) ;2 else counter++
((set! counter 0) (countdown(- i 1)))) ;1 else counter=0
))))))
測試:(lab2 '(9 9 9 (0) (0) (0) (0) 9 9 9 9 9 9 (0)9 9 (0) 9 9 9 9 9 9) 0 0)
,但得到這樣的:application: not a procedure; expected a procedure that can be applied to arguments given: #<void> arguments.: #<void>
如何解決? 請幫我((
太感謝你了!你真的幫助了我! – Nikkola
使用'add1'比使用'+ 1'更好嗎? –
@Fawful在這裏有很多事情要改變,不使用'add1'是所有問題中最少的。 – uselpa