Constructing lists using sequences with two different actions

Aarnout Brombacher shared this question 3 years ago
Answered

Greetings!

In the attached construction I have:

1) list001 of four points {{A,B,C,D}}

2) list110 that uses a "join(sequence(sequence({ _action 1_ },i,1,n),j,1,m)" structure to create a list that is dependent on list001 of the from {{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_}} which in turn is used to create the blue polygons in the construction

3) list120 that uses a "join(sequence(sequence({ _action 2_ },i,1,n),j,1,m)" structure to create a list that us dependent on list001 of the from {{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_}} which in turn is used to create the red polygons in the construction

The problem with this approach is that as I try to go to deeper levels, it become quite inefficient because I now have to repeat the construction 2^n times per level

What I would really like to do is to create a list that combines these two lists into one list in one step. What I have in mind is:

join(sequence(sequence({ _action 1_ },{ _action 2_ },i,1,n),j,1,m)" structure to create a list that is dependent on list001 of the from {{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_}}

I have tried:

join(sequence(sequence({ _action 1_ },{ _action 2_ },i,1,n),j,1,m)) this does not work

I have also tried:

join(sequence(sequence({ _action 1_ },i,1,n),j,1,m),sequence(sequence({ _action 2_ },i,1,n),j,1,m))) Although I get an output, it is not what I need:

{{{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_}},{{_,_,_,_},{_,_,_,_},{_,_,_,_},{_,_,_,_}}}

This outcome is not desirable because the same procedure on this list will not work.

I am aware that if I am successful, I would not be able to colour the different polygons different colours, but that is not a problem -- I have used the colours here to explain my thinking.

Please help!

Comments (4)

photo
1

you'll get one {} less with join() try join(list110,list120)

you can try join(join(join())) if you need eliminate levels of {{{{}}}}}

you can search sierpinsky in materilas for another easier methods of creation

photo
1

For lists, it is possible to eliminate all levels of nested braces using the command Flatten( ). Is that what you need?

Flatten(list)

https://wiki.geogebra.org/e...

photo
1

@mathmagic

Magic solution -- thank you so much -- exactly what I needed!

Thank you so much

Appreciated!

photo
1

@Javier

Thank you -- a new function to play with thanks! In this case it would take away too many of the "{}". Thank you again!

photo
© 2023 International GeoGebra Institute