MathGroup Archive 2009

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

Search the Archive

Re: Got a tip ?


singleCharToNumber[string_] := 
 First[ToCharacterCode[ToString[string]] - 
       96]

singleCharToNumber[a]
singleCharToNumber[b]
singleCharToNumber[z]

Out[21]= 1

Out[22]= 2

Out[23]= 26


   Of course, that will treat capitalized characters "strangely", but I'm sure you can cope with that case :)

               --C.O.

On Monday 23 March 2009 03:05:04 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
>  
> 



-- 
==========================================================
Curtis Osterhoudt
cfo at remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================


  • Prev by Date: Re: Question about how to graph the vector field for the
  • Next by Date: Re: Got a tip ?
  • Previous by thread: Re: Got a tip ?
  • Next by thread: Re: Got a tip ?