在cond中使用lisp输出某些内容
例如:在在cond中使用lisp输出某些内容,lisp,scheme,Lisp,Scheme,例如:在cond中调用length1时显示数字(或任何其他内容)。对于通用lisp,您可以使用(progn(…)(…)(…)将多个表达式组合成一个表达式 方案中的等效项是(begin(…)(…)…) 因此: 或者你想: (define length1 (lambda (lat) (cond ((null? lat) 0) (else (begin (display "hello world") (+ 1 (length1 (cdr lat)))))))) 这几乎耗尽了我的耐
cond
中调用length1时显示数字(或任何其他内容)。对于通用lisp,您可以使用(progn(…)(…)(…)
将多个表达式组合成一个表达式
方案中的等效项是(begin(…)(…)…)
因此:
或者你想:
(define length1
(lambda (lat)
(cond
((null? lat) 0)
(else (begin (display "hello world") (+ 1 (length1 (cdr lat))))))))
这几乎耗尽了我的耐心。如何显示当前计数编号
0 1 2 3 4…
?(+1(长度1(cdr lat))或(长度1(cdr lat))?在每个递归中,但这会调用自身,不是吗?是的,要显示号码,但不要调用lenght1两次
(define length1
(lambda (lat)
(cond
((null? lat) 0)
(else (begin (display "hello world") (+ 1 (length1 (cdr lat))))))))
(define length1
(lambda (lat)
(cond
((null? lat) 0)
(else (let ((or-anything-else (+ 1 (length1 (cdr lat)))))
(display or-anything-else)
or-anything-else)))