On Fri, 09 Jan 2015 15:36:21 +
FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via
Digitalmars-d-learn wrote:
On Fri, 09 Jan 2015 13:54:00 +
Robert burner Schadek via Digitalmars-d-learn
On Friday, 9 January 2015 at 15:57:21 UTC, ketmar via
Digitalmars-d-learn wrote:
On Fri, 09 Jan 2015 15:36:21 +
FrankLike via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com
wrote:
On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via
Digitalmars-d-learn wrote:
On Fri, 09 Jan
On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via
Digitalmars-d-learn wrote:
On Fri, 09 Jan 2015 13:54:00 +
Robert burner Schadek via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via
Digitalmars-d-learn wrote:
if you
iday, 9 January 2015 at 07:41:07 UTC, ketmar via
Digitalmars-d-learn wrote:
On Fri, 09 Jan 2015 07:10:14 +
FrankLike via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com
wrote:
On Thursday, 8 January 2015 at 15:15:59 UTC, Robert burner
Schadek wrote:
use canFind like such:
On Fri, 09 Jan 2015 09:36:01 +
FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
Sorry,it's only a example .Thank you work hard,but it's
not what I want.
'indexOfAny ' function should do this work.
”he is at home ,[home,office,”sea,plane], in
On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via
Digitalmars-d-learn wrote:
std.regex can use CTFE to compile regular expressions (yet it
sometimes
slower than non-CTFE variant), and i mean that we compile
regexp before
doing alot of searches, not before each single search. if you
have
On Fri, 09 Jan 2015 14:11:49 +
Robert burner Schadek via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via
Digitalmars-d-learn wrote:
std.regex can use CTFE to compile regular expressions (yet it
sometimes
slower
On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via
Digitalmars-d-learn wrote:
if you *really* concerned with speed here, you'd better
consider using
regular expressions. as regular expression can be precompiled
and then
search for multiple words with only one pass over the source
string. i
On Fri, 09 Jan 2015 13:54:00 +
Robert burner Schadek via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via
Digitalmars-d-learn wrote:
if you *really* concerned with speed here, you'd better
consider using
regular
be creative! ;-)
import std.algorithm, std.stdio;
void main () {
string s = he is at plane;
if (findAmong!((string a, string b) = b.canFind(a))([s],
[home, office, sea, plane]).length) {
writeln(got it!);
} else {
writeln(alas...);
}
}
or:
import
On Fri, 09 Jan 2015 12:46:53 +
FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
The code is the best,and it's better than indexOfAny in C#:
import std.algorithm, std.stdio;
void main ()
{
auto places = [ home, office, sea,plane];
auto strWhere = He
On Friday, 9 January 2015 at 10:02:53 UTC, ketmar via
Digitalmars-d-learn wrote:
import std.algorithm, std.stdio;
void main () {
string s = he is at home;
if ([home, office, sea, plane].canFind!((a, string
b) = b.canFind(a))(s)) {
writeln(got it!);
} else {
On Fri, 09 Jan 2015 13:06:09 +
FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
On Friday, 9 January 2015 at 10:02:53 UTC, ketmar via
Digitalmars-d-learn wrote:
import std.algorithm, std.stdio;
void main () {
string s = he is at home;
if
On Friday, 9 January 2015 at 14:21:04 UTC, ketmar via
Digitalmars-d-learn wrote:
heh. regexps *are* fast enough. it's hard to beat well-optimised
generated thingy on a complex grammar. ;-)
I don't see your point, anyway I think he got his help or at
least some help.
On Thursday, 8 January 2015 at 15:15:59 UTC, Robert burner
Schadek wrote:
use canFind like such:
bool a = canFind(strs,s) = 1;
let the compiler figger out what the types of the parameter are.
canFind is work for such as :
bool x = canFind([exe,lib,a,dll],a );
but can't work for
On Fri, 09 Jan 2015 07:10:14 +
FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
On Thursday, 8 January 2015 at 15:15:59 UTC, Robert burner
Schadek wrote:
use canFind like such:
bool a = canFind(strs,s) = 1;
let the compiler figger out what the types
On Wednesday, 7 January 2015 at 17:08:55 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
Try this:
http://dlang.org/phobos-prerelease/std_algorithm#.findAmong
T
You mean ? The result is not that I want to get!
---test.d--
import std.stdio,
On Wednesday, 7 January 2015 at 17:08:55 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
Try this:
http://dlang.org/phobos-prerelease/std_algorithm#.findAmong
T
Thank you,it can work. but it's not what I want.
---test.d--
import std.stdio,
use canFind like such:
bool a = canFind(strs,s) = 1;
let the compiler figger out what the types of the parameter are.
FrankLike:
But now I want to know in a string (like hello.exe or
hello.a,or hello.dll or hello.lib ) whether contains any
of them: [exe,dll,a,lib].
Seems this:
http://rosettacode.org/wiki/File_extension_is_in_extensions_list#D
Bye,
bearophile
On Wednesday, 7 January 2015 at 15:11:57 UTC, John Colvin wrote:
On Wednesday, 7 January 2015 at 14:54:51 UTC, FrankLike wrote:
I want to know whether the string strs contains
'exe','dll','a','lib',in c#,
I can do : int index =
indexofany(strs,[exe,dll,a,lib]);
but in D: I must to do like
I want to know whether the string strs contains
'exe','dll','a','lib',in c#,
I can do : int index = indexofany(strs,[exe,dll,a,lib]);
but in D: I must to do like this:
findStr(strs,[exe,lib,dll,a]))
bool findStr(string strIn,string[] strFind)
{
bool bFind = false;
On Wednesday, 7 January 2015 at 14:54:51 UTC, FrankLike wrote:
I want to know whether the string strs contains
'exe','dll','a','lib',in c#,
I can do : int index =
indexofany(strs,[exe,dll,a,lib]);
but in D: I must to do like this:
findStr(strs,[exe,lib,dll,a]))
bool findStr(string
std.algorithm.find has several overloads, one of which takes
multiple needles. The same is true for std.algorithm.canFind
Quoting from the relevant std.algorithm.find overload docs:
Finds two or more needles into a haystack.
string strs =hello.exe;
string[] s =[lib,exe,a,dll];
auto a =
Try this:
http://dlang.org/phobos-prerelease/std_algorithm#.findAmong
T
--
MACINTOSH: Most Applications Crash, If Not, The Operating System Hangs
On Wednesday, 7 January 2015 at 15:57:18 UTC, FrankLike wrote:
On Wednesday, 7 January 2015 at 15:11:57 UTC, John Colvin wrote:
On Wednesday, 7 January 2015 at 14:54:51 UTC, FrankLike wrote:
I want to know whether the string strs contains
'exe','dll','a','lib',in c#,
I can do : int index =
On Wednesday, 7 January 2015 at 16:02:25 UTC, bearophile wrote:
FrankLike:
But now I want to know in a string (like hello.exe or
hello.a,or hello.dll or hello.lib ) whether contains any
of them: [exe,dll,a,lib].
Seems this:
http://rosettacode.org/wiki/File_extension_is_in_extensions_list#D
27 matches
Mail list logo