Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Would you rather write something functionally or imperatively?
import scalaz._
import Scalaz._
case class Score(offline: Int, online: Int)
val scores = List(Score(100, 200), Score(103, 99), Score(12, 0))
// Written functionally:
val (offlineScores, onlineScores) = scores.foldMap(score => (score.offline,
// Written imperatively:
var workingOfflineScores = 0
var workingOnlineScores = 0
for (score <- scores) {
workingOfflineScores += score.offline
workingOnlineScores +=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.