countUntil to print all the index of a given string.

Andrew aabrown24 at hotmail.com
Mon Feb 26 00:47:38 UTC 2018


On Sunday, 25 February 2018 at 13:25:56 UTC, Vino wrote:
> On Sunday, 25 February 2018 at 03:41:27 UTC, Jonathan M Davis 
> wrote:
>> On Sunday, February 25, 2018 02:58:33 Seb via 
>> Digitalmars-d-learn wrote:
>>> [...]
>>
>> That will help eventually, but it requires a compiler flag, so 
>> it's really not going to help for code in general right now, 
>> and the fact that that DIP does nothing to solve the problem 
>> of how to create exception messages without allocating them on 
>> the GC heap means that exceptions in general are still 
>> frequently going to result in allocations unless you jump 
>> through several hoops to be able to create an exception 
>> message that's in a static array or malloc-ed or something. 
>> So, I don't know how much it's going to help in practice 
>> outside of code where the programmer is absolutely determined 
>> to have no GC allocations.
>>
>>> [...]
>>
>> Yeah. There does tend to be a correlation between @nogc and 
>> whether a range is lazy, but it's not guaranteed, so I'm 
>> inclined to think that it's a poor idea to rely on it and that 
>> it's just ultimately better to look at the documentation or 
>> even the code.
>>
>> - Jonathan M Davis
>
> Hi All,
>
>   Sorry, I am not able to see any correlation between the 
> raised topic and the conversation that is happening in this 
> forum, could any one please explain on of what is going on and 
> how do you thing that this conversation is related to the topic 
> raised, if not would suggest you to open a new topic.
>
> From,
> Vino.B

I think this will work:

import std.container;
import std.algorithm;
import std.range;
import std.stdio;

void main () {
auto a = Array!string("Test1", "Test2", "Test3", "Test1", 
"Test2");
auto b = Array!string("Test1", "Test2", "Test3");
foreach(i; b[])
   a[].enumerate.filter!(a => a[1] == i).map!(a => 
a[0]).SList!size_t[].writeln;


More information about the Digitalmars-d-learn mailing list