Created
April 18, 2016 14:11
-
-
Save saturov/27bc8f4445dd83cedb08bb872289724d 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
fun eval(expr: Expr): Double = when(expr) { | |
is Expr.Const -> expr.number | |
is Expr.Sum -> eval(expr.e1) + eval(expr.e2) | |
Expr.NotANumber -> Double.NaN | |
// ветка else не требуется, так как покрыты все возможные сценарии | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment