Перенос страниц
This commit is contained in:
parent
4d57446057
commit
4c954c9186
129 changed files with 14 additions and 15 deletions
|
@ -0,0 +1,18 @@
|
|||
T[] find(T)(T[] haystack, T needle)
|
||||
{
|
||||
while (haystack.length > 0 && haystack[0] != needle)
|
||||
{
|
||||
haystack = haystack[1 .. $];
|
||||
}
|
||||
return haystack;
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
// Проверка способностей к обобщению
|
||||
double[] d = [ 1.5, 2.4 ];
|
||||
assert(find(d, 1.0) == null);
|
||||
assert(find(d, 1.5) == d);
|
||||
string[] s = [ "one", "two" ];
|
||||
assert(find(s, "two") == [ "two" ]);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue