Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 17th, 2012  |  syntax: D  |  size: 0.83 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Tuple!(size_t[char],size_t) baseCounter( const ref string[] sequences ){
  2.         alias Tuple!(size_t[char], size_t) Result;
  3.         Result result;
  4.         size_t         length       = 0;
  5.         size_t[char][] baseNumbers  = new size_t[char][](sequences.length);
  6.         foreach(index, ref seq; parallel(sequences)){
  7.             foreach(ref letter; seq ){
  8.                 if( letter in baseNumbers[index]) baseNumbers[index][letter]++;
  9.                 else baseNumbers[index][letter] = 1;
  10.             }
  11.             length += seq.length;
  12.         }
  13.         foreach(baseNumber; baseNumbers){
  14.             foreach( key, value; baseNumber ){
  15.                 if( key in result[0] ) result[0][key] += value;
  16.                 else result[0][key] = value;
  17.             }
  18.         }
  19.         result[1] = length;
  20.         return result;
  21.     }