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計劃]
- 3. 你用Scheme Scheme宏做了些什麼?
- 4. facetime:// url scheme
- 5. BST-Smallest Scheme
- 6. REST http scheme
- 7. Scheme Let語句
- 8. openURL tel-scheme iPhone
- 9. College Work - Scheme
- 10. Scheme或Common Lisp
- 11. SCHEME | λ與λ?
- 12. Yammer URL scheme android
- 13. Scheme Inverse List Function
- 14. Posn in scheme/DrRacket
- 15. Gmail like URL scheme
- 16. Scheme或Common Lisp?
- 17. Scheme vs Common Lisp
- 18. 如何在Scheme中錄製單個按鍵?
- 19. clojure中是否有類似「andmap」的函數?
- 20. url scheme meteor:// app/..... meteorjs
- 21. Scheme刪除列表
- 22. 如何安裝Scheme?
- 23. URL scheme「prefs:root = PASS」iOS10
- 24. Scheme編程語言
- 25. Scheme while while循環
- 26. Lisp(Scheme)Newton方法
- 27. Lisp和Scheme中的WebSockets庫?
- 28. Kadane算法在Scheme(球拍)
- 29. Scheme - if語句的語法
- 30. Scheme中的多維向量?
所有這些功能都切斯計劃用戶指南中詳細記錄。 – erjiang