Skip to content

Instantly share code, notes, and snippets.

@lnds
Created January 10, 2016 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lnds/f6e4bc18a75530d5d358 to your computer and use it in GitHub Desktop.
Save lnds/f6e4bc18a75530d5d358 to your computer and use it in GitHub Desktop.
Otra forma de implementar validar
def validar(tam:Int, accion:String) : Option[Array[Int]] =
if (accion.exists(c => !c.isDigit) None
else {
val num = accion.map(c => c.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