【发布时间】:2020-09-04 20:51:24
【问题描述】:
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
(define (flatmap proc seq)
(accumulate append nil (map proc seq)))
以上是SICP的一个代码sn-p,在Scheme中。为什么需要flatmap 过程? flatmap和map有什么区别?
【问题讨论】:
标签: scheme sicp map-function flatmap