Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reversing iteration of range iteration and list iteration loops #174

Open
cardillan opened this issue Nov 3, 2024 · 0 comments
Open

Reversing iteration of range iteration and list iteration loops #174

cardillan opened this issue Nov 3, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@cardillan
Copy link
Owner

In release 2.5.0, vararg functions were added. The argument list passed to a function can only be accessed through list iteration loops (for now), which only supports accessing the elements in their given order.

It might be useful to be able to also iterate through the values in a reversed order, perhaps to perform some initialization and then corresponding de-initialization in the opposite order. Other use cases may emerge over time.

It is also worth noting that Mindcode doesn't have a decreasing range iteration loop. While this functionality can be easily encoded using other types of loops, it might make sense to support reversed iteration for range iteration loops as well.

What is now needed is to find a good syntax. Some possibilities include:

  • for a in reversed value1, value2, value3 do <loop body> end;
  • for a in value1, value2, value3 backwards do <loop body> end;
  • for i in reversed start ... stop do <loop body> end;
  • for i in start ... stop backwards do <loop body> end;: here descending would be better, but it doesn't fit well with the list iteration loop.
@cardillan cardillan added the enhancement New feature or request label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant