Skip to content

Instantly share code, notes, and snippets.

@odwrotnie
odwrotnie / currency-words-pl.scala
Created January 28, 2012 14:26
Słownie kwota w złotych
case class Currency(name: String, short: String, p: String, left: Boolean = false) {
def digits(value: Double) = append("%.2f" format value, short)
def words(value: Double) = {
val before = w(value.toLong)
val after = w(((value * 100.0f) % 100).toLong)
List(before, after).filterNot(_.isEmpty).zip(List(short, p)).
map(t => List(t._1, t._2)).flatten.mkString(" ").trim
}