Scheme Andmap\ormap-chez方案

Scheme Andmap\ormap-chez方案,scheme,chez-scheme,Scheme,Chez Scheme,我试图在chez方案中查找有关andmap&ormap操作的信息 尽管如此,我还是不明白这些操作的用途,以及它和map之间的区别。在pseudo Scheme中 (andmap f xs) == (fold and #t (map f xs)) (ormap f xs) == (fold or #f (map f xs)) 除了: 您不能以这种方式使用和和或 andmap和ormap会使处理列表短路 也就是说,除了稍微不同的短路行为 (andmap f (list x1 x2 x3

我试图在chez方案中查找有关andmap&ormap操作的信息

尽管如此,我还是不明白这些操作的用途,以及它和map之间的区别。

在pseudo Scheme中

(andmap f xs)  ==  (fold and #t (map f xs))
(ormap  f xs)  ==  (fold or  #f (map f xs))
除了:

  • 您不能以这种方式使用
  • andmap
    ormap
    会使处理列表短路
  • 也就是说,除了稍微不同的短路行为

    (andmap f (list x1 x2 x3 ...))  ==  (and (f x1) (f x2) (f x3) ...)
    (ormap  f (list x1 x2 x3 ...))  ==  (or  (f x1) (f x2) (f x3) ...)
    

    由practical-scheme.net提供:

    (ormap procedure list1 list2 ...)
    
    过程
    按顺序应用于列表的相应元素,直到列表耗尽或过程返回真值

    (andmap procedure list1 list2 ...)
    
    过程
    按顺序应用于列表的相应元素,直到列表耗尽或过程返回假值


    我想这是值得一提的,因为这个StackOverflow问题是Google上的第一个结果。

    所有这些功能都在Chez Scheme用户指南中有详细的说明。
    (andmap procedure list1 list2 ...)