Skip to content

Instantly share code, notes, and snippets.

@hasankucuk
Created May 19, 2020 10:35
Show Gist options
  • Select an option

  • Save hasankucuk/dbfb402212747d6b7a95b1e43751fbcb to your computer and use it in GitHub Desktop.

Select an option

Save hasankucuk/dbfb402212747d6b7a95b1e43751fbcb to your computer and use it in GitHub Desktop.
val numbers = mutableListOf(0, 1, 2, 3, 4, 5)
val runningReduceSum = numbers.runningReduce() { sum, item -> sum + item} // [0, 1, 3, 6, 10, 15]
val runningFoldSum = numbers.runningFold(10) { sum, item -> sum + item} // [10, 10, 11, 13, 16, 20, 25]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment