Continuing yesterday’s example, I must say I’m really starting to enjoy writing Scala. It brings me back to my old days of learning R - my first programming language.

def computeCost(usage: Int): Double = {
  if (usage > 750) usage * 0.15 else usage * 0.50
}
ds.map(u => computeCost(u.usage))

def computeCostColumn(d: Usage): UsageCost = {
  UsageCost(d.uid, d.user, d.usage, computeCost(d.usage))
}
ds.map(u => computeCostColumn(u)).show()

There’s just something really enjoyable about simply stringing together functions. I’ve been using Python for the past few years, but the Object-Oriented Programming (OOP) never appealed to me.