add sources

This commit is contained in:
Alexander Zhirov 2023-02-26 01:19:12 +03:00
parent fcd25eea52
commit 7ce631a648
21 changed files with 548 additions and 2 deletions

View file

@ -0,0 +1,20 @@
T1[] find(T1, T2)(T1[] longer, T2[] shorter)
if (is(typeof(longer[0 .. 1] == shorter) : bool))
{
while (longer.length >= shorter.length)
{
if (longer[0 .. shorter.length] == shorter)
{
break;
}
longer = longer[1 .. $];
}
return longer;
}
unittest
{
double[] d1 = [ 6.0, 1.5, 2.25, 3 ];
float[] d2 = [ 1.5, 2.25 ];
assert(find(d1, d2) == d1[1 .. $]);
}