1
A
回答
3
在僞方案,
(andmap f xs) == (fold and #t (map f xs))
(ormap f xs) == (fold or #f (map f xs))
不同之處在於:
- 你不能以這種方式使用
and
和or
。 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) ...)
0
Petite Chez Scheme Version 8.3
Copyright (c) 1985-2011 Cadence Research Systems
> (define (andmap f xs)
(cond ((null? xs) #t)
((f (car xs))
(andmap f (cdr xs)))
(else #f)))
> (define (ormap f xs)
(cond ((null? xs) #f)
((f (car xs)) #t)
(else (ormap f (cdr xs)))))
> (andmap even? '(2 4 6 8 10))
#t
> (andmap even? '(2 4 5 6 8))
#f
> (ormap odd? '(2 4 6 8 10))
#f
> (ormap odd? '(2 4 5 6 8))
#t
相關問題
- 1. Python是否有andmap/ormap?
- 2. chez scheme special lambda
- 3. 如何在Ubuntu上安裝Petite Chez Scheme?
- 4. Chez Scheme:Macroexpand implementation
- 5. Petite Chez Scheme(線程)這兩個列表之間有什麼不同?
- 6. 使用本地和ormap
- 7. 加密[嬌小Chez計劃]
- 8. Scheme - 檢測aux關鍵字
- 9. 如何導入相對於主文件而不是當前目錄的文件? ((Chez)Scheme)
- 10. 在chez計劃中使用匹配
- 11. 使用chez方案執行當前的s表達式
- 12. 你用Scheme Scheme宏做了些什麼?
- 13. REST url scheme
- 14. JsFiddle-like color scheme
- 15. Yammer URL scheme android
- 16. sqlalchemy oracle scheme
- 17. 錯誤:for:undefined(Scheme)
- 18. Posn in scheme/DrRacket
- 19. Apple Music URL Scheme
- 20. Scheme Let語句
- 21. Curriculum using Scheme
- 22. facetime:// url scheme
- 23. College Work - Scheme
- 24. Scheme或Common Lisp?
- 25. Scheme對輸出
- 26. Preorder In Scheme
- 27. SCHEME | λ與λ?
- 28. openURL tel-scheme iPhone
- 29. DrRacket/Scheme circle undefined
- 30. Gmail like URL scheme
所有這些功能都切斯計劃用戶指南中詳細記錄。 – erjiang