Created
January 10, 2016 16:57
-
-
Save lnds/fb0eee1489ffa46a6de4 to your computer and use it in GitHub Desktop.
Validar en F#
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
let validar tam accion = | |
let cars = [for c in accion -> c] | |
if List.exists (fun c -> not (Char.IsDigit c)) cars then List.empty<int> | |
else | |
let org = List.map (fun c -> (int c) - (int '0')) cars | |
let num = List.distinct org | |
if (List.length org <> List.length num) || (List.length num <> tam) then List.empty<int> | |
else num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment