Reputation: 12651
For base 62 encoding, I need all 62 alphanumeric characters. The F# range operator offers a nice shorthand for this.
let alphaNumericCharacters =
seq {
yield! [|'a'..'z'|]
yield! [|'A'..'Z'|]
yield! [|'0'..'9'|]
} |> Array.ofSeq
This is nice and concise, but I'm greedy. Is there a way of doing this in one line?
Upvotes: 3
Views: 89
Reputation: 8452
If your feeling funny:
let alphaNumericCharacters = [|Char.MinValue..Char.MaxValue|] |> Array.filter Char.IsLetterOrDigit
Upvotes: 0
Reputation: 4295
let alphaNumericCharacters = ['a'..'z'] @ ['A'..'Z'] @ ['0'..'9'] |> List.toArray
Upvotes: 1
Reputation: 62975
let alphaNumericCharacters = Array.concat [| [|'0'..'9'|]; [|'A'..'Z'|]; [|'a'..'z'|] |]
Upvotes: 2