[Date Index] [Thread Index] [Author Index]
Re: Got a tip ?
Something like this? f[c_String] := First[ToCharacterCode[c] - ToCharacterCode["a"] + 1] /; StringLength[c] === 1 gives In:= f["z"] Out= 26 Adriano Pascoletti 2009/3/23 Fabrizio <Tekcitizen at hotmail.com> > 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 >