Created
April 22, 2016 02:15
-
-
Save LucasMaloney/11f907b0126ed528296cf0a66c512c21 to your computer and use it in GitHub Desktop.
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
// Generates "case safe" versions Salesforce record ids | |
let flagsToChar flags = if flags < 26 then 'A' + (char flags) else '0' + (char (flags - 26)) | |
let getCaseFlag id i j = if Char.IsUpper(id, i * 5 + j) then 1 <<< j else 0 | |
let getCaseChar id i = | |
Seq.init 5 (getCaseFlag id i) | |
|> Seq.sum | |
|> flagsToChar | |
let getCaseSuffix id = | |
Seq.init 3 (getCaseChar id) | |
|> String.Concat | |
let getCaseSafeId id = id + (getCaseSuffix id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment