MathGroup Archive 1996

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

Search the Archive

Re: Inverse of IntegerDigits? and "Index" function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3964] Re: Inverse of IntegerDigits? and "Index" function?
  • From: wagner at motel6.cs.colorado.edu (Dave Wagner)
  • Date: Mon, 13 May 1996 01:46:34 -0400
  • Organization: University of Colorado, Boulder
  • Sender: owner-wri-mathgroup at wolfram.com

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] ====


  • Prev by Date: Re: Inverse of IntegerDigits? and "Index" function?
  • Next by Date: Lists
  • Previous by thread: Re: Inverse of IntegerDigits? and "Index" function?
  • Next by thread: Re: Inverse of IntegerDigits? and "Index" function?