question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is your feature request related to a problem? Please describe.

R.filter doesn’t expose index to the predicate function. Let’s create a function that does and call it filterIndexed.

Describe the solution you’d like

filterIndexed((v, idx) => idx === 0, [1, 2, 3); // => [1]

Possible implementation

const filterIndexed = R.addIndex(R.filter);

Describe alternatives you’ve considered

Additional context

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
char0ncommented, Sep 13, 2020

@jprask sure, go ahead!

0reactions
jpraskcommented, Nov 12, 2020

@char0n Yeah, my apologies on the delay here, ended up busy with some parallel stuff. Starting it now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

filterIndexed - Kotlin Programming Language
Returns a list containing only elements matching the given predicate. import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> ...
Read more >
Kotlin filter lambda array using iteration index
filterIndexed function is suited exactly for this case: array.filterIndexed { index, value -> index % n == 0 }.
Read more >
How to access Index of Element while Filtering Kotlin List?
To access index of the elements while filtering elements in a Kotlin List, use filterIndexed() function. For each element in the List, the...
Read more >
filterIndexed - Kotlin Programming Language
Returns a list containing only elements matching the given predicate. Parameters. predicate - function that takes the index of an element and the...
Read more >
filterIndexed - kotlin.collections - W3cubDocs
Returns a list containing only elements matching the given predicate. import kotlin.test.* fun main(args: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found