dlang-book/book/04-массивы-ассоциативные-массивы-и-строки/src/chapter-4-1-8/app.d

15 lines
456 B
D
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import std.stdio;
void main()
{
auto array = [0, 2, 4, 6, 8, 10];
array = array[0 .. $ - 2];
// Су­же­ние спра­ва на два эле­мен­та
assert(array == [0, 2, 4, 6]);
array = array[1 .. $];
// Су­же­ние сле­ва на один эле­мент
assert(array == [2, 4, 6]);
array = array[1 .. $ - 1];
// Су­же­ние с обе­их сто­рон
assert(array == [4]);
}