Created
January 10, 2016 16:43
-
-
Save lnds/db41725f31dbb6c425eb to your computer and use it in GitHub Desktop.
Ejemplo de If en Scala. Notar la primera condición
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
def validar(tam:Int, accion:String) : Option[Array[Int]] = | |
if (accion.exists(!_.isDigit)) | |
None | |
else { | |
val num = accion.map(_.toInt - '0'.toInt).distinct | |
if (num.length == tam && num.length == accion.length) | |
Some(num.toArray) | |
else | |
None | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment