MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Got a tip ?


f[x_String] := ToCharacterCode[x][[1]] - 96

f["a"]

1

f["A"]

-31

f /@ CharacterRange["a", "h"]

{1,2,3,4,5,6,7,8}

f /@ CharacterRange["A", "H"]

{-31,-30,-29,-28,-27,-26,-25,-24}



Bob Hanlon


On Mon, Mar 23, 2009 at 7:42 AM , Fabrizio wrote:

> Hello,
>
> I want to write a function that translates its argument (which is a 
> letter of the alphabet) into a numerical value.
>
> f[a] = 1
> f[b] = 2


  • Prev by Date: Re: Got a tip ?
  • Next by Date: Re: Got a tip ?
  • Previous by thread: Re: Got a tip ?
  • Next by thread: Re: Got a tip ?