array question

seany seany at uni-bonn.de
Sun Dec 8 07:42:48 PST 2013


On Sunday, 8 December 2013 at 13:47:43 UTC, Ali Çehreli wrote:
> On 12/08/2013 03:51 AM, seany wrote:
>
> > consider the follwoing:
> >
> > import tango.io.Stdout, tango.io.Path, tango.text.Util;
> > import std.algorithm, std.string , std.stdio, std.array,
> std.conv,
> > std.regex, std.typecons;
> >
> > //i know al imports are not necessary for this example, just
> ^c^v from
> > my actual code
> >
> > alias string[] surSegments
>
> There are the missing semicolon above and other problems with 
> the code.
>
> > void makeHashmap(T,R)(T[] plainArr, string hashes, out R[]
> hashMap)
> > {
> >      //first split the hashes
> >      string [] hashesArr = std.algorithm.splitter(hashes,
> ',').array;
> >
> >      for(int i = 0; i < plainArr.length; i++)
> >      {
> >          R hashElement;
> >          for(int j = 0; j < hashesArr.length; j++)
> >          {
> >              hashElement[hashesArr[j]] =  = plainArr[i][j];
>
> I think you wanted to append:
>
>             hashElement[hashesArr[j]] ~= plainArr[i][j];
>
> What helped me see what was going on was a bunch of pragma(msg) 
> lines:
>
>             pragma(msg, typeof(hashElement));
>             pragma(msg, typeof(hashesArr[j]));
>             pragma(msg, typeof(hashElement[hashesArr[j]]));
>             pragma(msg, typeof(plainArr[i][j]));
>
> Ali


no i wanted to set hashElement[hashesArr[j]] =  plainArr[i][j];
I realise that it had become string[][string][]

sorry my bad


More information about the Digitalmars-d-learn mailing list