Properties
Similar Topics
Statistics
Comments
2
Participants
2
Subscribers
2
Votes
1
Views
143
Share
How to get the current number of iterations
Answered
I'm trying to complete a permutation using the iteration command.
https://www.geogebra.org/ca...
In the expression below, "n" with underlined should be the number of iterations, but how can I get the current number of iterations?
Iteration(Join(Zip(Sequence(Insert(n, q, m), m, 1, n), q, p)), p, {{{1}}}, n)
Thanks.
 GeoGebra
 Help
 Partners

Contact us
 Feedback & Questions
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 +43 677 6137 2693
© 2021 International GeoGebra Institute
Afaik there is no way to access the current number of iterations directly.
In your case it's not really necessary though, because n is always the length of q, so you could just replace "n" by "length(q)". Although I guess that you rather want to replace it by "length(q)+1", assuming that you are trying to generate permutations. (And you could even start with "{{}}" instead of "{{1}}" so that n matches the length of the permutations.)
A general workaround is to keep track of the current iteration by making it part of the list that is iterated over. It's always a bit annoying to write though and makes the Iteration command line even less readable.
Afaik there is no way to access the current number of iterations directly.
In your case it's not really necessary though, because n is always the length of q, so you could just replace "n" by "length(q)". Although I guess that you rather want to replace it by "length(q)+1", assuming that you are trying to generate permutations. (And you could even start with "{{}}" instead of "{{1}}" so that n matches the length of the permutations.)
A general workaround is to keep track of the current iteration by making it part of the list that is iterated over. It's always a bit annoying to write though and makes the Iteration command line even less readable.
Got it. length(q)+1 is a great idea. Thank you very much.
Comments have been locked on this page!