Re: Find indexes of elements matching a given value in an array

2012-09-10 Thread Samuele Carcagno
Thank you guys, that's fantastic! I'll try out your functions.

Re: Find indexes of elements matching a given value in an array

2012-09-09 Thread timotheecour
Here's a modification to: 1) hide the intermediate struct (as usual in std.algorithm, I forgot what this trick is called) 2) work with ranges, not just arrays (ie will work with iota, see unittest) 3) accept input without "in" attribute; 4) accept arbitrary predicate, not just "==x" Please co

Re: Find indexes of elements matching a given value in an array

2012-09-09 Thread bearophile
Samuele Carcagno: I would like to find the indexes of all the elements of an array matching a certain value. I could simply loop over all the elements to do the job, but I was hoping for some ready made function that also works across different types (ints, floats etc...). I have written yo

Find indexes of elements matching a given value in an array

2012-09-09 Thread Samuele Carcagno
I would like to find the indexes of all the elements of an array matching a certain value. I could simply loop over all the elements to do the job, but I was hoping for some ready made function that also works across different types (ints, floats etc...). I saw the countUntil function in std.