Smart pascal source code
type
TRec = record
Field: Integer
end;
procedure WriteLnArray(a: array of TRec);
var
i: Integer;
begin
Writeln(IntToStr(Length(a)) + ':{');
for i := 0 to High(a) do
begin
if i > 0 then
Writeln(',');
Writeln(IntToStr(a[i].Field));
end;
Writeln('}');
end;
{ TApplication }
procedure TApplication.RunApp;
var
r: TRec;
a: array of TRec;
begin
a.Add(r);
r.Field := 1;
a.Add(r);
r.Field := -1;
a.Insert(0, r);
WriteLnArray(a); // 3:{-1,0,1}
r.Field := 123;
WriteLnArray(a); // 3:{-1,0,1}
a.Delete(1);
WriteLnArray(a); // 2:{-1,1}
var r = {Field:0};
var a = [];
a.push(Clone$TRec(r));
r.Field = 1;
a.push(Clone$TRec(r));
r.Field = -1;
a.splice(0,0,Clone$TRec(r));
WriteLnArray(a);
r.Field = 123;
WriteLnArray(a);
a.splice(1,1);
WriteLnArray(a);
function WriteLnArray(a$1) {
var i = 0;
WriteLn(((a$1.length).toString()+":{"));
var $temp1;
for(i=0,$temp1=a$1.length;i<$temp1;i++) {
if (i>0) {
WriteLn(",");
}
WriteLn((a$1[i].Field).toString());
}
WriteLn("}");
};
function Copy$TRec(s,d) {
d.Field=s.Field;
return d;
}
function Clone$TRec($) {
return {
Field:$.Field
}
}