[Date Index] [Thread Index] [Author Index]
Re: Got a tip ?
If you're willing to allow your inputs to be one-character strings: alf="abcdefghijklmnopqrstuvwxyz"; f[ltr_]:= First@First@StringPosition[alf,ltr] f["b"] 2 If you _really_ want plain, unadorned single-letter symbols as inputs, replace alf above by alf=ToExpression@Characters[alf] g[char_] := First@First@Position[letters, char] g[b] 2 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 > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305