Для матриц - ElementsByRow ElementsByCol ElementsWithIndexes ReadMatrInteger ReadMatrReal
This commit is contained in:
parent
f1ecd956a2
commit
56e79f50fb
|
|
@ -2391,9 +2391,16 @@ namespace PascalABCCompiler
|
|||
|
||||
public string FindPCUFileName(string UnitName)
|
||||
{
|
||||
return FindFileInDirectories(UnitName + CompilerOptions.CompiledUnitExtension, CompilerOptions.OutputDirectory, CompilerOptions.SourceFileDirectory, CompilerOptions.SearchDirectory);
|
||||
if (PCUFileNamesDictionary.ContainsKey(UnitName))
|
||||
return PCUFileNamesDictionary[UnitName];
|
||||
|
||||
string fpfn = null;
|
||||
fpfn = FindFileInDirectories(UnitName + CompilerOptions.CompiledUnitExtension, CompilerOptions.OutputDirectory, CompilerOptions.SourceFileDirectory, CompilerOptions.SearchDirectory);
|
||||
|
||||
PCUFileNamesDictionary[UnitName] = fpfn;
|
||||
return fpfn;
|
||||
}
|
||||
|
||||
|
||||
public string FindPCUFileNameWithoutSources(string UnitName, string FileDir)
|
||||
{
|
||||
return FindFileInDirectories(UnitName + CompilerOptions.CompiledUnitExtension, FileDir, CompilerOptions.OutputDirectory, CompilerOptions.SourceFileDirectory, CompilerOptions.SearchDirectory);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "2";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "1406";
|
||||
public const string Revision = "1415";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=2
|
||||
%REVISION%=1406
|
||||
%COREVERSION%=0
|
||||
%REVISION%=1415
|
||||
%MINOR%=2
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.2.0.1406'
|
||||
!define VERSION '3.2.0.1415'
|
||||
|
|
|
|||
|
|
@ -1675,6 +1675,11 @@ function MatrFill<T>(m,n: integer; x: T): array [,] of T;
|
|||
function MatrGen<T>(m,n: integer; gen: (integer,integer)->T): array [,] of T;
|
||||
/// Транспонирует двумерный массив
|
||||
function Transpose<T>(a: array [,] of T): array [,] of T;
|
||||
/// Возвращает матрицу m на n целых, введенных с клавиатуры
|
||||
function ReadMatrInteger(m,n: integer): array [,] of integer;
|
||||
/// Возвращает матрицу m на n вещественных, введенных с клавиатуры
|
||||
function ReadMatrReal(m,n: integer): array [,] of real;
|
||||
|
||||
|
||||
// -----------------------------------------------------
|
||||
//>> Подпрограммы для создания кортежей # Subroutines for tuple generation
|
||||
|
|
@ -1968,6 +1973,7 @@ const
|
|||
PARAMETER_STEP_MUST_BE_GREATER_0 = 'Параметр step должен быть > 0!!The step parameter must be not greater than 0';
|
||||
PARAMETER_FROM_OUT_OF_RANGE = 'Параметр from за пределами диапазона!!The from parameter out of bounds';
|
||||
PARAMETER_TO_OUT_OF_RANGE = 'Параметр to за пределами диапазона!!The to parameter out of bounds';
|
||||
ARR_LENGTH_MUST_BE_MATCH_TO_MATR_SIZE = 'Размер одномерного массива не согласован с размером двумерного массива!!The 1-dim array length does not match 2-dim array size';
|
||||
|
||||
// -----------------------------------------------------
|
||||
// WINAPI
|
||||
|
|
@ -8883,6 +8889,7 @@ function SystemSliceQuestion<T>(Self: List<T>; situation: integer; from,&to,step
|
|||
begin
|
||||
Result := SystemSliceListImplQuestion(Self,situation,from,&to,step);
|
||||
end;
|
||||
|
||||
// -----------------------------------------------------
|
||||
//>> Методы расширения типа array [,] of T # Extension methods for array [,] of T
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -8998,6 +9005,47 @@ begin
|
|||
Swap(Self[i,k1],Self[i,k2])
|
||||
end;
|
||||
|
||||
/// Меняет строку k двумерного массива на другую строку
|
||||
procedure SetRow<T>(Self: array [,] of T; k: integer; a: array of T); extensionmethod;
|
||||
begin
|
||||
if a.Length<>Self.ColCount then
|
||||
raise new System.ArgumentException(GetTranslation(ARR_LENGTH_MUST_BE_MATCH_TO_MATR_SIZE));
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
Self[k,j] := a[j]
|
||||
end;
|
||||
|
||||
/// Меняет столбец k двумерного массива на другой столбец
|
||||
procedure SetCol<T>(Self: array [,] of T; k: integer; a: array of T); extensionmethod;
|
||||
begin
|
||||
if a.Length<>Self.RowCount then
|
||||
raise new System.ArgumentException(GetTranslation(ARR_LENGTH_MUST_BE_MATCH_TO_MATR_SIZE));
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
Self[i,k] := a[i]
|
||||
end;
|
||||
|
||||
/// Возвращает по заданному двумерному массиву последовательность (i,j,a[i,j])
|
||||
function ElementsWithIndexes<T>(Self: array [,] of T): sequence of (integer,integer,T); extensionmethod;
|
||||
begin
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
yield (i,j,Self[i,j])
|
||||
end;
|
||||
|
||||
/// Возвращает по заданному двумерному массиву последовательность его элементов по строкам
|
||||
function ElementsByRow<T>(Self: array [,] of T): sequence of T; extensionmethod;
|
||||
begin
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
yield Self[i,j]
|
||||
end;
|
||||
|
||||
/// Возвращает по заданному двумерному массиву последовательность его элементов по столбцам
|
||||
function ElementsByCol<T>(Self: array [,] of T): sequence of T; extensionmethod;
|
||||
begin
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
yield Self[i,j]
|
||||
end;
|
||||
|
||||
// Реализация операций с матрицами - только после введения RowCount и ColCount
|
||||
function MatrRandom(m: integer; n: integer; a,b: integer): array [,] of integer;
|
||||
|
|
@ -9050,6 +9098,22 @@ begin
|
|||
Result[i,j] := a[j,i]
|
||||
end;
|
||||
|
||||
function ReadMatrInteger(m,n: integer): array [,] of integer;
|
||||
begin
|
||||
Result := new integer[m,n];
|
||||
for var i:=0 to m-1 do
|
||||
for var j:=0 to n-1 do
|
||||
Result[i,j] := ReadInteger;
|
||||
end;
|
||||
|
||||
function ReadMatrReal(m,n: integer): array [,] of real;
|
||||
begin
|
||||
Result := new real[m,n];
|
||||
for var i:=0 to m-1 do
|
||||
for var j:=0 to n-1 do
|
||||
Result[i,j] := ReadReal;
|
||||
end;
|
||||
|
||||
// -----------------------------------------------------
|
||||
//>> Методы расширения типа array of T # Extension methods for array of T
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -9740,6 +9804,9 @@ begin
|
|||
Result := Self.Matches(reg,options).Select(m->m.Value);
|
||||
end;
|
||||
|
||||
/// Удовлетворяет ли строка регулярному выражению
|
||||
function IsMatch(Self: string; reg: string; options: RegexOptions := RegexOptions.None): boolean; extensionmethod := Regex.IsMatch(Self, reg, options);
|
||||
|
||||
/// Удаляет в строке все вхождения указанных строк
|
||||
function Remove(Self: string; params targets: array of string): string; extensionmethod;
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -20,18 +20,14 @@ namespace VisualPascalABC.OptionsContent
|
|||
{
|
||||
var sl = 50;
|
||||
this.contentEngine = contentEngine;
|
||||
System.Threading.Thread.Sleep(sl); // SSM 07.11.16 ïîñòàâèë íà âñÿêèé ñëó÷àé çàäåðæêè - èíîãäà îêíî îïöèé ïðè îòêðûòèè íåàêòèâíîå
|
||||
InitializeComponent();
|
||||
System.Threading.Thread.Sleep(sl);
|
||||
foreach (IOptionsContent content in contentEngine.ContentList)
|
||||
{
|
||||
TreeNode tn = new TreeNode(content.ContentName);
|
||||
tvContentList.Nodes.Add(tn);
|
||||
nodes.Add(tn, content);
|
||||
}
|
||||
System.Threading.Thread.Sleep(sl);
|
||||
PascalABCCompiler.StringResources.SetTextForAllObjects(this, strprefix);
|
||||
System.Threading.Thread.Sleep(sl);
|
||||
}
|
||||
|
||||
private void btOk_Click(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace VisualPascalABC
|
|||
Workbench.WidgetController.SetStopEnabled(false);
|
||||
Workbench.WidgetController.SetCompilingButtonsEnabled(true);
|
||||
Workbench.WidgetController.SetDebugButtonsEnabled(true);
|
||||
if (IsOneProgramStarted())
|
||||
//if (IsOneProgramStarted())
|
||||
Workbench.WidgetController.SetOptionsEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ namespace VisualPascalABC
|
|||
Workbench.WidgetController.SetStopEnabled(false);
|
||||
Workbench.WidgetController.SetCompilingButtonsEnabled(true);
|
||||
Workbench.WidgetController.SetDebugButtonsEnabled(true);
|
||||
if (IsOneProgramStarted())
|
||||
//if (IsOneProgramStarted())
|
||||
Workbench.WidgetController.SetOptionsEnabled(true);
|
||||
}
|
||||
RunTabs[fileName].Run = false;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1680,6 +1680,37 @@
|
|||
<i Type="Field">MaxDouble = real . MaxValue</i>
|
||||
</ICtx>
|
||||
</Node>
|
||||
<Node Name="Методы расширения типа array [,] of T">
|
||||
<FileName>\PABCSystem.pas</FileName>
|
||||
<Text>//>> Методы расширения типа array [,] of T # Extension methods for array [,] of T</Text>
|
||||
<OCtx>
|
||||
<i Type="Method">function Sin ( c : Complex ) : = Complex . Sin ( c )</i>
|
||||
<i Type="Method">function Power ( c , power : Complex ) : = Complex . Pow ( c , power )</i>
|
||||
<i Type="Method">function Log10 ( c : Complex ) : = Complex . Log10 ( c )</i>
|
||||
<i Type="Method">function Log ( c : Complex ) : = Complex . Log ( c )</i>
|
||||
<i Type="Method">function Exp ( c : Complex ) : = Complex . Exp ( c )</i>
|
||||
<i Type="Method">function Cos ( c : Complex ) : = Complex . Cos ( c )</i>
|
||||
<i Type="Method">function Conjugate ( c : Complex ) : = Complex . Conjugate ( c )</i>
|
||||
<i Type="Method">function Abs ( c : Complex ) : = Complex . Abs ( c )</i>
|
||||
<i Type="Method">function Sqrt ( c : Complex ) : = Complex . Sqrt ( c )</i>
|
||||
<i Type="Method">function CplxFromPolar ( magnitude , phase : real ) : = Complex . FromPolarCoordinates ( magnitude , phase )</i>
|
||||
<i Type="Method">function Cplx ( re , im : real ) : = new Complex ( re , im )</i>
|
||||
<i Type="PAS_TreeNode">
|
||||
</i>
|
||||
</OCtx>
|
||||
<ICtx>
|
||||
<i Type="Method">function Low ( i : System . Array ) : integer</i>
|
||||
<i Type="Method">function High ( i : System . Array ) : integer</i>
|
||||
<i Type="Method">function Length ( a : &Array ) : integer</i>
|
||||
<i Type="Method">function Length ( a : &Array ; dim : integer ) : integer</i>
|
||||
<i Type="Method">function Copy ( a : &Array ) : &Array</i>
|
||||
<i Type="Method">procedure Sort < T > ( a : array of T )</i>
|
||||
<i Type="Method">procedure Sort < T > ( a : array of T ; cmp : ( T , T ) - > integer )</i>
|
||||
<i Type="Method">procedure Sort < T > ( a : array of T ; less : ( T , T ) - > boolean )</i>
|
||||
<i Type="Method">procedure Sort < T > ( l : List < T > )</i>
|
||||
<i Type="Method">procedure Sort < T > ( l : List < T > ; cmp : ( T , T ) - > integer )</i>
|
||||
</ICtx>
|
||||
</Node>
|
||||
<Node Name="Методы расширения типа integer">
|
||||
<FileName>\PABCSystem.pas</FileName>
|
||||
<Text>//>> Методы расширения типа integer # Extension methods for integer</Text>
|
||||
|
|
|
|||
|
|
@ -1675,6 +1675,11 @@ function MatrFill<T>(m,n: integer; x: T): array [,] of T;
|
|||
function MatrGen<T>(m,n: integer; gen: (integer,integer)->T): array [,] of T;
|
||||
/// Транспонирует двумерный массив
|
||||
function Transpose<T>(a: array [,] of T): array [,] of T;
|
||||
/// Возвращает матрицу m на n целых, введенных с клавиатуры
|
||||
function ReadMatrInteger(m,n: integer): array [,] of integer;
|
||||
/// Возвращает матрицу m на n вещественных, введенных с клавиатуры
|
||||
function ReadMatrReal(m,n: integer): array [,] of real;
|
||||
|
||||
|
||||
// -----------------------------------------------------
|
||||
//>> Подпрограммы для создания кортежей # Subroutines for tuple generation
|
||||
|
|
@ -1968,6 +1973,7 @@ const
|
|||
PARAMETER_STEP_MUST_BE_GREATER_0 = 'Параметр step должен быть > 0!!The step parameter must be not greater than 0';
|
||||
PARAMETER_FROM_OUT_OF_RANGE = 'Параметр from за пределами диапазона!!The from parameter out of bounds';
|
||||
PARAMETER_TO_OUT_OF_RANGE = 'Параметр to за пределами диапазона!!The to parameter out of bounds';
|
||||
ARR_LENGTH_MUST_BE_MATCH_TO_MATR_SIZE = 'Размер одномерного массива не согласован с размером двумерного массива!!The 1-dim array length does not match 2-dim array size';
|
||||
|
||||
// -----------------------------------------------------
|
||||
// WINAPI
|
||||
|
|
@ -8883,6 +8889,7 @@ function SystemSliceQuestion<T>(Self: List<T>; situation: integer; from,&to,step
|
|||
begin
|
||||
Result := SystemSliceListImplQuestion(Self,situation,from,&to,step);
|
||||
end;
|
||||
|
||||
// -----------------------------------------------------
|
||||
//>> Методы расширения типа array [,] of T # Extension methods for array [,] of T
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -8998,6 +9005,47 @@ begin
|
|||
Swap(Self[i,k1],Self[i,k2])
|
||||
end;
|
||||
|
||||
/// Меняет строку k двумерного массива на другую строку
|
||||
procedure SetRow<T>(Self: array [,] of T; k: integer; a: array of T); extensionmethod;
|
||||
begin
|
||||
if a.Length<>Self.ColCount then
|
||||
raise new System.ArgumentException(GetTranslation(ARR_LENGTH_MUST_BE_MATCH_TO_MATR_SIZE));
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
Self[k,j] := a[j]
|
||||
end;
|
||||
|
||||
/// Меняет столбец k двумерного массива на другой столбец
|
||||
procedure SetCol<T>(Self: array [,] of T; k: integer; a: array of T); extensionmethod;
|
||||
begin
|
||||
if a.Length<>Self.RowCount then
|
||||
raise new System.ArgumentException(GetTranslation(ARR_LENGTH_MUST_BE_MATCH_TO_MATR_SIZE));
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
Self[i,k] := a[i]
|
||||
end;
|
||||
|
||||
/// Возвращает по заданному двумерному массиву последовательность (i,j,a[i,j])
|
||||
function ElementsWithIndexes<T>(Self: array [,] of T): sequence of (integer,integer,T); extensionmethod;
|
||||
begin
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
yield (i,j,Self[i,j])
|
||||
end;
|
||||
|
||||
/// Возвращает по заданному двумерному массиву последовательность его элементов по строкам
|
||||
function ElementsByRow<T>(Self: array [,] of T): sequence of T; extensionmethod;
|
||||
begin
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
yield Self[i,j]
|
||||
end;
|
||||
|
||||
/// Возвращает по заданному двумерному массиву последовательность его элементов по столбцам
|
||||
function ElementsByCol<T>(Self: array [,] of T): sequence of T; extensionmethod;
|
||||
begin
|
||||
for var j:=0 to Self.ColCount-1 do
|
||||
for var i:=0 to Self.RowCount-1 do
|
||||
yield Self[i,j]
|
||||
end;
|
||||
|
||||
// Реализация операций с матрицами - только после введения RowCount и ColCount
|
||||
function MatrRandom(m: integer; n: integer; a,b: integer): array [,] of integer;
|
||||
|
|
@ -9050,6 +9098,22 @@ begin
|
|||
Result[i,j] := a[j,i]
|
||||
end;
|
||||
|
||||
function ReadMatrInteger(m,n: integer): array [,] of integer;
|
||||
begin
|
||||
Result := new integer[m,n];
|
||||
for var i:=0 to m-1 do
|
||||
for var j:=0 to n-1 do
|
||||
Result[i,j] := ReadInteger;
|
||||
end;
|
||||
|
||||
function ReadMatrReal(m,n: integer): array [,] of real;
|
||||
begin
|
||||
Result := new real[m,n];
|
||||
for var i:=0 to m-1 do
|
||||
for var j:=0 to n-1 do
|
||||
Result[i,j] := ReadReal;
|
||||
end;
|
||||
|
||||
// -----------------------------------------------------
|
||||
//>> Методы расширения типа array of T # Extension methods for array of T
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -9740,6 +9804,9 @@ begin
|
|||
Result := Self.Matches(reg,options).Select(m->m.Value);
|
||||
end;
|
||||
|
||||
/// Удовлетворяет ли строка регулярному выражению
|
||||
function IsMatch(Self: string; reg: string; options: RegexOptions := RegexOptions.None): boolean; extensionmethod := Regex.IsMatch(Self, reg, options);
|
||||
|
||||
/// Удаляет в строке все вхождения указанных строк
|
||||
function Remove(Self: string; params targets: array of string): string; extensionmethod;
|
||||
begin
|
||||
|
|
|
|||
Loading…
Reference in a new issue