【发布时间】:2015-01-15 21:25:56
【问题描述】:
我有一个'(x y . rest) 形式的列表(具有可选参数数量的 lambda 形式)。
我需要检查我是否有这种情况,但我似乎没有检查。我打算做的是搜索. 是否是列表的成员。
> (memq '\. '(x y z . rest))
Exception in memq: improper list (x y z . rest)
Type (debug) to enter the debugger.
> (memq . '(x y z . rest))
Exception: invalid syntax (x y z . rest)
Type (debug) to enter the debugger.
> (memv '\. '(x y z \. rest))
(\x2E; rest) ;this worked but my input is of the form '(x y z . rest) and not '(x y z \. rest)
【问题讨论】:
-
看看SRFI-1中的不当列表。
-
看看Dot notation in scheme。您真正需要寻找的是链中的最后一个
cdr是空列表还是其他。 -
当我们谈论 SRFI 1 时,它提供了一个
dotted-list?谓词,这似乎正是 OP 所寻求的。
标签: scheme