Skip to content

Instantly share code, notes, and snippets.

@lnds
Created January 10, 2016 16:57
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/fb0eee1489ffa46a6de4 to your computer and use it in GitHub Desktop.
Save lnds/fb0eee1489ffa46a6de4 to your computer and use it in GitHub Desktop.
Validar en F#
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