Mathematica 54 41 Bytes
With an absolutely clever suggestion from LegionMammal978 that saves 13 bytes.
If[#>0,FromLetterNumber,,LetterNumber]@#&
If[#>0,FromLetterNumber,,LetterNumber]
serves the sole purpose of deciding whether to apply FromLetterNumber
or LetterNumber
to the input.
#>0
will be satisfied if the input, #
, is a number, in which case FromLetterNumber
will be selected.
However #>0
will be neither true nor false if #
is a letter, and LetterNumber
will be selected instead.
If[#>0,FromLetterNumber,,LetterNumber]@#&["d"]
4
If[#>0,FromLetterNumber,,LetterNumber]@#&[4]
d
In Mathematica, FromLetterNumber
and LetterNumber
will also work with other alphabets. This requires only a few more bytes.
If[# > 0, FromLetterNumber, , LetterNumber][#, #2] &[4, "Greek"]
If[# > 0, FromLetterNumber, , LetterNumber][#, #2] &[4, "Russian"]
If[# > 0, FromLetterNumber, , LetterNumber][#, #2] &[4, "Romanian"]
δ
г
b
If[# > 0, FromLetterNumber, , LetterNumber][#, #2] &[δ, "Greek"]
If[# > 0, FromLetterNumber, , LetterNumber][#, #2] &[г, "Russian"]
If[# > 0, FromLetterNumber, , LetterNumber][#, #2] &[b, "Romanian"]
4
4
4
26
as an integer or"26"
as a string, or are both allowed? \$\endgroup\$