Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Wordy.Core.Data
- open System
- module IDGenerator =
- let private random = new System.Random()
- let charsAllowed = [|
- "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "j";"k"; "m"; "n"; "p"; "q"; "r"; "s"; "t"; "u"; "v"; "w"; "x"; "y";"z";
- "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9";
- "A"; "B"; "C"; "D"; "E"; "F"; "G"; "H"; "J"; "K"; "L"; "M"; "N"; "P"; "Q"; "R"; "S"; "T"; "U"; "V"; "W"; "X"; "Y"; "Z"|]
- let charBase = charsAllowed.Length
- let rec newID = function
- | length, id when String.IsNullOrEmpty(id) -> newID(length, "")
- | length, id when length < 1 -> id
- | length, id -> newID(length - 1, charsAllowed.[random.Next(charBase)] + id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement