Skip to main content
deleted 5 characters in body
Source Link
LCarvalho
  • 9.3k
  • 5
  • 40
  • 97

I've been struggeling with the command riffle.

input: list = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}}

list = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13,14, 15}}

How do I use riffle like this, but add 1 to "X", every time it gets inserted? So when it has inserted "X" 5 times, it would be X5, instead of just "X".

"X" is a string.

Riffle[list, "X", 3]

 {{1, 2, 3}, {4, 5, 6}, X, {7, 8, 9}, {10, 11, 12}, X, {13, 14, 15}}

The output I am looking for:

Output :{{1, 2, 3}, {4, 5, 6}, X1, {7, 8, 9}, {10, 11, 12}, X2, {13, 14, 15}}`

{{1, 2, 3}, {4, 5, 6}, X1, {7, 8, 9}, {10, 11, 12}, X2, {13, 14, 15}}

I've been struggeling with the command riffle.

input: list = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}}

How do I use riffle like this, but add 1 to "X", every time it gets inserted? So when it has inserted "X" 5 times, it would be X5, instead of just "X".

"X" is a string.

Riffle[list, "X", 3]

 {{1, 2, 3}, {4, 5, 6}, X, {7, 8, 9}, {10, 11, 12}, X, {13, 14, 15}}

The output I am looking for:

Output :{{1, 2, 3}, {4, 5, 6}, X1, {7, 8, 9}, {10, 11, 12}, X2, {13, 14, 15}}`

I've been struggeling with the command riffle.

list = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13,14, 15}}

How do I use riffle like this, but add 1 to "X", every time it gets inserted? So when it has inserted "X" 5 times, it would be X5, instead of just "X".

"X" is a string.

Riffle[list, "X", 3]

 {{1, 2, 3}, {4, 5, 6}, X, {7, 8, 9}, {10, 11, 12}, X, {13, 14, 15}}

The output I am looking for:

{{1, 2, 3}, {4, 5, 6}, X1, {7, 8, 9}, {10, 11, 12}, X2, {13, 14, 15}}

Tweeted twitter.com/StackMma/status/673929032216526848
Source Link

Riffle an element with +1 every time

I've been struggeling with the command riffle.

input: list = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}}

How do I use riffle like this, but add 1 to "X", every time it gets inserted? So when it has inserted "X" 5 times, it would be X5, instead of just "X".

"X" is a string.

Riffle[list, "X", 3]

 {{1, 2, 3}, {4, 5, 6}, X, {7, 8, 9}, {10, 11, 12}, X, {13, 14, 15}}

The output I am looking for:

Output :{{1, 2, 3}, {4, 5, 6}, X1, {7, 8, 9}, {10, 11, 12}, X2, {13, 14, 15}}`