Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between `runningFold` and `scan` methods in the Kotlin collections library?

Tags:

kotlin

Comparing the pages for both methods scan and runningFold (from kotlin.collections), the two appear to be identical save for the name.

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/scan.html

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/running-fold.html

like image 810
docgunthrop Avatar asked Jan 25 '23 19:01

docgunthrop


1 Answers

Apparently there is no difference, check this out:

runningFold() and runningReduce() are introduced as synonyms for scan() and scanReduce(). Such names are more consistent with the related functions fold() and reduce(). In the future, scan() will be available along with runningFold() since it’s a commonly known name for this operation. The experimental scanReduce(), however, will be deprecated and removed soon.

source: https://blog.jetbrains.com/kotlin/2020/05/1-4-m2-standard-library/

like image 148
Luciano Ferruzzi Avatar answered Feb 15 '23 23:02

Luciano Ferruzzi