Skip to main content
Add SubstitutionSystem solution
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59

Update

From this by @azerbajdzan, which introduced me to SubstitutionSystem

SubstitutionSystem[{n_ :> n+1}, {1,0}, 8]//Flatten

(* {1,0,2,1,3,2,4,3,5,4,6,5,7,6,8,7,9,8} *) 

Original Answer

Flatten@NestList[#+1&,{1,0},8]

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

In addition

Array[{#,#-1}&,9,1,Join]

and

Array[{#+1,#}&, 9,0,Join]==Array[{#,#-1}&, 9,1,Join]

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten
Flatten@NestList[#+1&,{1,0},8]

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

In addition

Array[{#,#-1}&,9,1,Join]

and

Array[{#+1,#}&, 9,0,Join]==Array[{#,#-1}&, 9,1,Join]

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten

Update

From this by @azerbajdzan, which introduced me to SubstitutionSystem

SubstitutionSystem[{n_ :> n+1}, {1,0}, 8]//Flatten

(* {1,0,2,1,3,2,4,3,5,4,6,5,7,6,8,7,9,8} *) 

Original Answer

Flatten@NestList[#+1&,{1,0},8]

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

In addition

Array[{#,#-1}&,9,1,Join]

and

Array[{#+1,#}&, 9,0,Join]==Array[{#,#-1}&, 9,1,Join]

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten
added 48 characters in body
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59
Flatten@NestList[#+1&,{1,0},8]

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

In addition

Array[{#,#-1}&,9,1,Join]

and

Array[{#+1,#}&, 9,0,Join]==Array[{#,#-1}&, 9,1,Join]

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten
Flatten@NestList[#+1&,{1,0},8]

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten
Flatten@NestList[#+1&,{1,0},8]

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

In addition

Array[{#,#-1}&,9,1,Join]

and

Array[{#+1,#}&, 9,0,Join]==Array[{#,#-1}&, 9,1,Join]

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten
added 61 characters in body
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59
NestList[#+{1,1}&Flatten@NestList[#+1&, {1,0},8]//Flatten

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten
NestList[#+{1,1}&, {1,0},8]//Flatten

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

Flatten@NestList[#+1&,{1,0},8]

{1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8}

Original Post

NestList[#+{1,1}&, {1,0},8]//Flatten
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59
Loading