1
#lang scheme
(define consecutive?
(lambda(a b c)
((cond [(and (= (- b a) 1) (or (= (- c b) 1) (= (- a c) 1))) "true"]
[(and (= (- a b) 1) (or (= (- c a) 1) (= (- b c) 1))) "true"]
[(and (= (- c a) 1) (or (= (- a b) 1) (= (- b c) 1))) "true"]
[(and (= (- a c) 1) (or (= (- c b) 1) (= (- b a) 1))) "true"]
[else "false"]))))
(consecutive? 2 3 4)
爲什麼這是給出錯誤?「應用程序:不是程序」,同時檢查連續的數字
這不是你錯誤的來源,但是:考慮使用'#t'和'#f'來代替字符串,並且在你的'cond'子句中考慮這個重複。 – Inaimathi
[Racket PLAI Application not a Procedure]的可能重複(http://stackoverflow.com/questions/19022704/racket-plai-application-not-a-procedure)。除此之外,如果您使用scheme標籤搜索[「not a procedure」(http://stackoverflow.com/search?q=+%22not+a+procedure%22+%5Bscheme%5D))在已經回答的地方會發現很多問題。 '((cond ...))'期望'(cond ...)'產生一個結果'r',這是一個過程,然後嘗試調用'r'。 –