【发布时间】:2011-08-27 00:24:32
【问题描述】:
我正在编写一个递归枚举函数,但我在某处遇到了一个简单的错误。
这是应该发生的:
(enum 1 0.5 2.5)
> (1.0 1.5 2.0 2.5)
代码如下:
(define enum
(lambda (start step stop)
(if (not (<= stop start))
(cons start (enum (+ start step) step stop))
('(stop))
)))
编辑:
我得到的错误(来自 Impromptu (http://impromptu.moso.com.au/))是:
> (print (enum 0 0.5 2.5))
:ERROR: position:(0) in function "enum"
illegal function
Trace: enum
【问题讨论】:
-
你遇到了什么错误?
标签: algorithm recursion scheme lisp enumeration