Please cut and paste the code in my previous answer and use it verbatim. Here, you've actually made some changes to the code to make it incorrect: instead of your original one-armed if
, you've made it even worse, a zero-armed if
.
A correctly-formatted two-armed if
expression looks like this (noting that expr1
and expr2
are supposed to be flush with (indented to the same level as) test
):
(if test
expr1
expr2)
This means that if test
evaluates to a truthy value (anything other than nil
), then expr1
is evaluated, and its value is the value of the if
expression; otherwise expr2
is used instead. In the code snippet I had, test
is (null (first (rest list)))
, expr1
is 0
, and expr2
is (+ (distance (car list) (first (rest list))) (helper-2 (rest list)))
.
The other nice thing about using my code snippet directly is that it's already formatted correctly for standard Lisp style, which makes it much more pleasant for other Lisp programmers to read.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…