Extend array_position function with instance number
See original GitHub issueCurrently array_position
only returns the first occurrence of the given element. We want to extend array_position
to take an additional parameter instance
similar to strpos
.
array_position(x, element, instance) -> bigint
For example, for array x: [1, 3, 2, 1, 4, 3, 2, 5, 4, 1]
:
array_position(x, 1) = 1 -- existing function
array_position(x, 1, 1) = 1 -- same as existing function with 2 input parameters
array_position(x, 1, 2) = 4 -- returns index of the second occurrence of 1
array_position(x, 5, 2) = 0 -- returns 0 because there is no second occurrence of 5
array_position(x, 1, -1) = 10 -- returns index of the first occurrence of 1 from the back
array_posision(x, 1, -2) = 4 -- returns index of the second occurrence of 1 from the back
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Ways to extend Array object in javascript - Stack Overflow
in 3rd way i want to extend the Array object internally Array3 class. How to do this so not to get "push is...
Read more >5. Working with Arrays and Loops - JavaScript Cookbook [Book]
In Example 5-2, an array is created with several elements, including multiple instances of a specific value. The splice method is then used...
Read more >Array Functions and Operators — Presto 0.278 Documentation
The [] operator is used to access an element of an array and is indexed starting ... the position of the instance -th...
Read more >Array - JavaScript - MDN Web Docs
Returns true if the argument is an array, or false otherwise. Creates a new Array instance with a variable number of arguments, regardless...
Read more >Array methods - The Modern JavaScript Tutorial
arr.forEach(function(item, index, array) { // ... do something with item });. For instance, this shows each element of the array:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rongrong thanks! That does the trick.
I use java 1.8. Try
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
and see whether it works.