【发布时间】:2021-06-16 23:37:24
【问题描述】:
为了使 C 函数短路(例如,出于测试目的),我可以将早期的 return 放在那里。例如:
int main(void) {
puts("Hello");
return;
...bunch of other code...
}
或者在 python 中做一个sys.exit(0)。有没有办法在 DrRacket / Scheme 中做到这一点?通常我会有一个包含几百行代码的工作簿,我只希望在退出之前运行前几个函数。例如:
#lang sicp
(define (filtr function sequence)
(if (null? sequence) nil
(let ((this (car sequence))
(rest (cdr sequence)))
(if (function this) (cons this (filtr function rest))
(filtr function rest)))))
(filtr (lambda (x) (> x 5)) '(1 2 3 4 5 6 7 8 9))
(exit) ; ?? something like this I can drop in to terminate execution?
...200 more lines of code...
这里有办法吗?
【问题讨论】: