Last active
December 23, 2015 06:29
-
-
Save davidgrenier/6594719 to your computer and use it in GitHub Desktop.
Convert Excel column to id
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 columnNum = | |
let charValues = | |
['A'..'Z'] | |
|> Seq.mapi (fun i c -> c, i + 1) | |
|> map | |
fun (code: string) -> | |
(Seq.toList code, (0,-1)) | |
||> List.foldBack(fun v (depth, total) -> depth + 1, total + (pown 26 depth * charValues.[v])) | |
|> snd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment