Menu

#866 Allow backward iteration over collection and supplier

5.2.0
unread
nobody
None
none
1
2025-12-03
2025-12-03
jfaucher
No

(deleted my comments in the RFE #865, to keep it focused on the new 'step' subkeyword)

Purpose: allow to iterate from last to first item over a collection or a supplier.
See this message in the help forum: Traversing an array in reverse order

Collection

loop item over collection backward
do item over collection backward

'backward' is just an example of subkeyword.
Could be 'reverse', or 'inverse', or ..., I don't know what is the better term.

A makeArray message is sent as usual to the collection, the navigation in the array is made in reverse order.

Supplier

loop with index myIndex item myItem over supplier for 3 backward
do with index myIndex item myItem over supplier for 3 backward

For a reverse iteration over a supplier, the Collection class and the Supplier class could support a reverseSupplier method which returns an instance of the ReverseSupplier class .

This ReverseSupplier class would be similar to the Supplier class, except for the order of navigation.

rexxref 2.4 DO : "11. The supplier can be any expression that evaluates to an object that supports a supplier method."

For this RFE, when using 'backward', the message "reverseSupplier" would be sent.

Note: The Stream class can't support a reverseSupplier.

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB