[Date Index] [Thread Index] [Author Index]
Re: Inverse of IntegerDigits? and "Index" function?
In article <4menl1$jva at dragonfly.wolfram.com>, <pehowland at taz.dra.hmg.gb> wrote: > >Excuse me if I'm being particularly inept this morning, but can anyone offer >any help on the following problems please? > >Inverse of IntegerDigits I wish I had a dollar for every time this question gets asked. (Okay, so I'd have about $5, but it's better than nothing.) You want to use: DigitsToInteger[d_List, b_:2] := Fold[b #1 + #2 &, 0, d] This function uses Horner's rule for expanding a polynomial. If you give it a second argument, you can specify the radix of the digits. By the way, it's probably no breach of national security to tell you that a function to do this is built into the next version of Mathematica. I mention this only to make the point that this question gets asked a lot, so don't feel too bad about it. Dave Wagner Principia Consulting (303) 786-8371 dbwagner at princon.com http://www.princon.com/princon ==== [MESSAGE SEPARATOR] ====