Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Quick Mathematica Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115270] Re: Quick Mathematica Question
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Thu, 6 Jan 2011 02:03:12 -0500 (EST)
  • References: <ig1i6l$6jj$1@smc.vnet.net>

On Jan 5, 2:46 am, Dean <deanrosent... at gmail.com> wrote:
> How would I program user-defined rules such as
>
> 0->1
> 1->10
>
> to give the output, and specify the number of recursions.
> For example, starting with 0,
>
> 0
> 1
> 10
> 101
> 10110
> ...
>
> Specified, 5 generations.
>
> --
> Dean Rosenthal
>
> cell: 646 733 6966
> www.deanrosenthal.org
> http://www.the-open-space.org/webmag/test1.html

FromDigits /@ NestList[
Replace[#, {0->1, 1->Sequence[1,0]}, {1}]&, {0}, 4]

{0, 1, 10, 101, 10110}


  • Prev by Date: Re: Quick Mathematica Question
  • Next by Date: Re: Quick Mathematica Question
  • Previous by thread: Re: Quick Mathematica Question
  • Next by thread: Re: Quick Mathematica Question