Sign in Join
FPDoc Onlineexperiment

Slice function

In unit System

Return part of an array.

Declaration

pascal
function Slice(const A: ArrayType; ACount: Integer): ArrayType2

Description

Slice returns the first ACount elements from the array A. It returns an array with the same element type as A, but this array is not assignment compatible to any other array, and can therefor only be used in open array arguments to functions.

See also

Example: ex113

pascal
Program Example113;

{ Program to demonstrate the Slice function. }

procedure ShowArray(const A: array of Integer);
var
  I: Integer;
begin
  for I := Low(A) to High(A) do
    WriteLn(I, ' : ', A[I]);
end;

begin
  ShowArray(Slice([1,2,3,4],2));
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.