[Issue 11990] New: map don't play nice with default values in function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 24 21:16:46 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11990

           Summary: map don't play nice with default values in function
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: knud at all-technology.com


--- Comment #0 from Knud <knud at all-technology.com> 2014-01-24 21:16:42 PST ---
The following code produce 
51
3 0 4
2 0 4
.
.
.
0 0 4
[5, 5, 5, 5, 5]
[2, 1, 1, 0, 1]

by commenting out the return statement in BW_count
and commenting in the other code we get the expected output.

51
3 0 50
2 0 50
.
.
.
0 0 50
[51, 51, 51, 51, 51]
[2, 1, 1, 0, 1]


//**** BW_count ****//
// string,string[] => int[]
// Count the number of suffix matches in Burrows Wheeler Transform
unittest
{

writeln(BW_count("TCCTCTATGAGATCCTATTCTATGAAACCTTCA$GACCAAAATTCTCCGGC",["CCT","CAC","GAG","CAG","ATC"]));
writeln([2,1,1,0,1]);

}

int[] BW_count(string str,string[] pat)
{
   int BW_count_pat(string sstr,uint start=0,uint end=str.length-1)
   {
     writeln(sstr.length," ",start," ",end);
     if (!sstr.length) return end-start+1;
     return  BW_count_pat(sstr[1..$],start,end);
   }
  writeln(str.length);
 /*  if (!pat.length) 
      return (int[]).init;
   return BW_count_pat(pat[0])~BW_count(str,pat[1..$]);
*/

  return pat.map!(BW_count_pat).array;

}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list