Re: how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-23 Thread Sean Kelly
On Nov 16, 2012, at 7:49 AM, bioinfornatics bioinfornat...@fedoraproject.org wrote: hi, I would like to count number of one ore more letter into a string or list of string (string[]) without use a for loop but instead using std.algorithm to compute efficiently. if you have: string

Re: how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-17 Thread bioinfornatics
thanks to all, then something as: --- Tuple!(size_t[char],size_t) baseCounter( const ref string[] sequences ){ alias Tuple!(size_t[char], size_t) Result; Result result; size_t length = 0; size_t[char][] baseNumbers =

Re: how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-17 Thread bearophile
bioinfornatics: should be faster, no ? If your purpose is to write a fast function to do this, then I suggest you to not use Phobos stuff in this function, and to not use associative arrays in it, and possibly to not use the heap. This is not going to give you assured faster code, but it's

how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-16 Thread bioinfornatics
hi, I would like to count number of one ore more letter into a string or list of string (string[]) without use a for loop but instead using std.algorithm to compute efficiently. if you have: string seq1 = ACGATCGATCGATCGCGCTAGCTAGCTAG; string[] seq2 = [ACGATCGATCGATCGCGCTAGCTAGCTAG,

Re: how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-16 Thread bearophile
bioinfornatics: I would like to count number of one ore more letter into a string or list of string (string[]) without use a for loop but instead using std.algorithm to compute efficiently. If it's speed you look for, then most times std.algorithm is not the solution. Basic loops are usually

Re: how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-16 Thread Simen Kjaeraas
On 2012-11-16, 16:49, bioinfornatics wrote: hi, I would like to count number of one ore more letter into a string or list of string (string[]) without use a for loop but instead using std.algorithm to compute efficiently. if you have: string seq1 = ACGATCGATCGATCGCGCTAGCTAGCTAG;

Re: how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-16 Thread bearophile
Simen Kjaeraas: There. Now it works, and returns a Tuple!(ulong,ulong)(8, 8). One thing I think is ugly in my implementation is acc + (seq == 'G'). This adds a bool and a ulong together. For more points, replace that with acc + (seq == 'G' ? 1 : 0). I use a pragmatic approach: I use such

Re: how to count number of letters with std.algorithm.count / std.algorithm.reduce / std.algorithm.map ?

2012-11-16 Thread Simen Kjaeraas
On 2012-11-16, 17:37, bearophile wrote: Simen Kjaeraas: There. Now it works, and returns a Tuple!(ulong,ulong)(8, 8). One thing I think is ugly in my implementation is acc + (seq == 'G'). This adds a bool and a ulong together. For more points, replace that with acc + (seq == 'G' ? 1 : 0).