擬似lsの実装
Posted feedbacks - D
Digital Mars D Compiler v1.015で動作確認しました。
see: プログラミング言語 D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import std.stdio;
import std.string;
import std.regexp;
void ls(string[] path_list, string path)
{
string[] rslt;
auto rgxp = RegExp(format("^%s([^/]+/?)", path));
foreach (i; path_list) {
if (-1 != rgxp.find(i)) {
rslt ~= rgxp.match(1);
}
}
string tmp;
foreach (i; rslt) {
tmp ~= format("\"%s\",", i);
}
writef("[%s]\n", chop(tmp));
}
/*
void main(char[][] args)
{
static string[] path_list = ["aaa/bbb", "aaa/ccc", "aaa/ddd/eee", "bbb/ddd/eee"];
ls(path_list, "aaa/");
ls(path_list, "aaa/ddd/");
}
*/
|



ところてん
#4212()
Rating1/3=0.33
[ reply ]