Re: Simple string membership test

2025-02-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, February 15, 2025 9:33:06 PM MST Andy Valencia via Digitalmars-d-learn wrote: > On Saturday, 15 February 2025 at 19:27:19 UTC, Ian wrote: > > canFind is Perfect. Thank you. > > If performance is an issue, putting them as keys in an > Associative Array and simply using "in" should scal

Re: Simple string membership test

2025-02-15 Thread Andy Valencia via Digitalmars-d-learn
On Saturday, 15 February 2025 at 19:27:19 UTC, Ian wrote: canFind is Perfect. Thank you. If performance is an issue, putting them as keys in an Associative Array and simply using "in" should scale nicely to even very large numbers of strings to search. Andy

Re: Simple string membership test

2025-02-15 Thread Ian via Digitalmars-d-learn
On Saturday, 15 February 2025 at 18:13:39 UTC, Sergey wrote: On Saturday, 15 February 2025 at 17:58:44 UTC, Ian wrote: Hi, What's the best (idiomatic) way of checking if a string is in a list of strings: ```d string v = "tofind"; if (v ismemberof ["abc", "def","tofind"]) etc(); ``` Thank

Re: Simple string membership test

2025-02-15 Thread Sergey via Digitalmars-d-learn
On Saturday, 15 February 2025 at 17:58:44 UTC, Ian wrote: Hi, What's the best (idiomatic) way of checking if a string is in a list of strings: ```d string v = "tofind"; if (v ismemberof ["abc", "def","tofind"]) etc(); ``` Thanks, ian canFind or countUntil https://dlang.org/phobos/std_a

Simple string membership test

2025-02-15 Thread Ian via Digitalmars-d-learn
Hi, What's the best (idiomatic) way of checking if a string is in a list of strings: ```d string v = "tofind"; if (v ismemberof ["abc", "def","tofind"]) etc(); ``` Thanks, ian