Last active
November 8, 2015 18:37
-
-
Save rhwlo/9508955802565f27c973 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
// a Modifier implements a modifier function | |
sealed abstract class Modifier { | |
def modify(measure: Measure): Measure | |
} | |
case class Prefix(prefix: String, modify(measure: Measure): Measure) extends Modifier | |
class Exponent(power: Int) extends Modifier { | |
def modify(measure: Measure): Measure = { | |
Range(1, power).foldLeft(measure)(case (m, _) => m.multiply(measure)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment