julia> parseint("4")4julia> parseint('4')no method parseint(Char,)julia> int('4')52
So how do I turn '4' into 4? I feel like parseint should work, but maybe I'm just missing something.
julia> a = '4'
'4'
julia> parseint("$a")
4
This works. Is this a good way?
julia> a = '4'
'4'
julia> String(a)
type cannot be constructed
Didn't think to try string. Thanks for the answers. Kevin the numbers are coming from a string I'm parsing that represents a sudoku. I'm implementing a solver like Norvig's but using IntSets for fun.
I think I saw some discussion about how int and Int are confusing, and relics of when DataType wasn't a thing. It seems that string and String are similar.
Maybe parseint(::Char) should be the common locus for subtracting '0' and 'a' or 'A' or whatever. We have that logic repeated in a number of places around the system.
parseint(c::Char) ='0' <= c <= '9' ? c-'0' :'a' <= c <= 'z' ? c-'a'+10 :'A' <= c <= 'Z' ? c-'A'+10 :error("invalid digit: $(repr(c))")
+1 to that definition Stefan. I think that's exactly what people would expect calling parseint on a Char.
-Jacob