[New Feature] Support array:some and array:every langlib functions #35481
Replies: 3 comments 1 reply
-
Minor detail - we "need to implement" this in array.bal (the array langlib), rather than "can implement". In the array langlib so that it is an array langlib function, in array.bal so that we are maintaining a 1:1 mapping with the spec.
Same comment as for |
Beta Was this translation helpful? Give feedback.
-
Please find the progress of the |
Beta Was this translation helpful? Give feedback.
-
Also see #35531 (comment) regarding |
Beta Was this translation helpful? Give feedback.
-
These are the two functions we need to support (Please check spec issue ballerina-platform/ballerina-spec#1005). For both cases, we can implement ballerina functions in array.bal.
array:some
This langlib function will take an array and a function pointer as parameters and returns a boolean.
In the implementation, we have to iterate over the elements in the input array and call the input function for each element. Therefore the input of the function should be an array element and it should return a boolean. If that function returns true we have to stop the iteration and return true. Please find the below flow diagram for a clear understanding.
array:every
The signature of this function is the same as the above function.
If the input function returns false we have to stop the iteration and return false. Please find the below flow diagram for a clear understanding.
Highly appreciate your input on this discussion.
Beta Was this translation helpful? Give feedback.
All reactions