- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想确定列表是否仅包含null
。 null?
似乎是显而易见的选择:
> (null? null)
#t
但是对其进行andmap
并没有达到我的预期:
> (andmap null? '(null))
#f
我是否误解了null?
或andmap
?我是 Racket 新手,但根据文档,这似乎根本不正确。
最佳答案
您的问题是 '(null)
不是包含 null
的列表(即空列表)。以下是一些可行的选项:
(andmap null? '(()))
(andmap null? `(,null))
或 (andmap null? (quasiquote (unquote null)))
(andmap null?(list null))
。发生情况的说明:标识符 null
绑定(bind)到表示空列表的值。当您执行 'null
时,这相当于 (quote null)
,意思是“给我一个代表标识符的符号,而不是它代表的内容”(就像自然语言中的引用一样) )。
您可以通过使用表示 null '()
的文字或使用 quasiquote
和 unquote
“转义”回来避免这种情况 Racket 。
有关引用的更多信息,请参阅 Guide entry就在上面。
关于null - andmap 和 null?返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16725426/
我想在我的列表中应用一系列测试并确保所有测试都通过。 Clojure 中是否有类似于“andmap”的函数? 最佳答案 您可以使用 every? : user=> (every? string? '(
我试图在 chez 方案中查找有关 andmap 和 ormap 操作的信息。 还是不明白这些操作的用途,和map有什么区别。 最佳答案 在伪方案中, (andmap f xs) == (fold
我想确定列表是否仅包含null。 null? 似乎是显而易见的选择: > (null? null) #t 但是对其进行andmap并没有达到我的预期: > (andmap null? '(null))
我正在使用 Racket 和 Dr. Racket。 有一个名为 andmap 的内置函数. andmap 的内置版本是这样工作的: > (andmap positive? '(1 2 3)) #t
我正在学习 Racket,我不知道如何在 andmap 函数中返回一个值: (define iguales 0) (andmap (lambda (x y) (cond
我是一名优秀的程序员,十分优秀!