My goal is to get a random emoticon, from a list, in F#.
I started with this:
let pickOne (icons: string) : char = icons.[Helpers.random.Next(icons.Length)]
let happySymbols = ""
let sadSymbols = ""
that doesn't work because:
"".Length
is returning 44 as length returns the number of chars in a string, which is not working well with unicode characters. I can't just divide by 2 because I may add some single byte characters in the string at some point.
Indexing doesn't work either:
let a = ""
a.[0]
will not return but I get some unknown character symbol.
so, plan B was: let's make this an array instead of a string:
let a = [| ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; ''; '' |]
this is not compiling, I'm getting:
Parse error Unexpected quote symbol in binding. Expected '|]' or other token.
why is that?
anyhow, I can make a list of strings and get it to work, but I'm curious: is there a "proper" way to make the first one work and take a random unicode character from a unicode string?
