Created
August 6, 2012 16:05
-
-
Save philcali/3275967 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val Dollar = """\$\s*(\d+\.\d+)\s*""".r | |
import Dollar.{ findFirstMatchIn => line } | |
import io.Source.{ fromFile => open} | |
val sum = (0.00 /: open("expenses.txt").getLines)(_ + line(_).map(_.group(1).toDouble).getOrElse(0.0)) | |
println("Total is: $%.2f" format sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment