From 084bc1632a62f7a2376f2b4ab0607e50ad2162fb Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Thu, 10 Sep 2020 00:58:58 +0300 Subject: [PATCH] a.Divs(b) NotDivs DivsAll a.DivsAny(2,3,5) if a.Divs(b) and a.NotDivs(5) then SF a.D(b) a.ND(b) --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/PABCSystem.pas | 38 +++++++++++++++++++++ TestSuite/CompilationSamples/SF.pas | 4 +++ bin/Lib/PABCSystem.pas | 30 ++++++++++++++++ bin/Lib/SF.pas | 4 +++ 8 files changed, 80 insertions(+), 4 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 7dde2f9d8..0f6044e50 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "7"; public const string Build = "1"; - public const string Revision = "2681"; + public const string Revision = "2683"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index 40b9a7914..d54906200 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=7 -%REVISION%=2681 +%REVISION%=2683 %COREVERSION%=1 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 475928303..12624598a 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.7.1.2681 +3.7.1.2683 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index e35412dbb..4dff24be5 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.7.1.2681' +!define VERSION '3.7.1.2683' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index e4d540d51..f560659b3 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -11833,6 +11833,36 @@ end; // ----------------------------------------------------- //>> Методы расширения типа integer # Extension methods for integer // ----------------------------------------------------- +/// Возвращает True если целое делится на указанное значение +function Divs(Self,d: integer): boolean; extensionmethod := Self mod d = 0; + +/// Возвращает True если целое не делится на указанное значение +function NotDivs(Self,d: integer): boolean; extensionmethod := Self mod d <> 0; + +/// Возвращает True если целое делится на одно из значений +function DivsAny(Self: integer; params a: array of integer): boolean; extensionmethod; +begin + Result := False; + for var i:=0 to a.High do + if Self mod a[i] = 0 then + begin + Result := True; + exit + end; +end; + +/// Возвращает True если целое делится на все значения +function DivsAll(Self: integer; params a: array of integer): boolean; extensionmethod; +begin + Result := True; + for var i:=0 to a.High do + if Self mod a[i] <> 0 then + begin + Result := False; + exit + end; +end; + /// Возвращает квадратный корень числа function Sqrt(Self: integer): real; extensionmethod; begin @@ -12112,6 +12142,14 @@ end; //------------------------------------------------------------------------------ //>> Методы расширения типа string # Extension methods for string //------------------------------------------------------------------------------ +/// Заменяет count вхождений подстроки oldStr на подстроку newStr в исходной строке +function Replace(Self: string; oldStr,newStr: string; count: integer): string; extensionmethod; +begin + var reg := new Regex(oldStr); + Result := reg.Replace(Self,newStr,count); +end; + + /// Возвращает True если значение находится между двумя другими function Between(Self: string; a, b: string): boolean; extensionmethod; begin diff --git a/TestSuite/CompilationSamples/SF.pas b/TestSuite/CompilationSamples/SF.pas index c414e4a0b..d508be097 100644 --- a/TestSuite/CompilationSamples/SF.pas +++ b/TestSuite/CompilationSamples/SF.pas @@ -69,6 +69,10 @@ function Prln(Self: char): char; extensionmethod := Self.Println; function Prln(Self: boolean): boolean; extensionmethod := Self.Println; function Prln(Self: string): string; extensionmethod := Self.Println; + +function D(Self,b: integer): boolean; extensionmethod := Self mod b = 0; +function ND(Self,b: integer): boolean; extensionmethod := Self mod b <> 0; + /// Записывает в min значение x если x> Методы расширения типа integer # Extension methods for integer // ----------------------------------------------------- +/// Возвращает True если целое делится на указанное значение +function Divs(Self,d: integer): boolean; extensionmethod := Self mod d = 0; + +/// Возвращает True если целое не делится на указанное значение +function NotDivs(Self,d: integer): boolean; extensionmethod := Self mod d <> 0; + +/// Возвращает True если целое делится на одно из значений +function DivsAny(Self: integer; params a: array of integer): boolean; extensionmethod; +begin + Result := False; + for var i:=0 to a.High do + if Self mod a[i] = 0 then + begin + Result := True; + exit + end; +end; + +/// Возвращает True если целое делится на все значения +function DivsAll(Self: integer; params a: array of integer): boolean; extensionmethod; +begin + Result := True; + for var i:=0 to a.High do + if Self mod a[i] <> 0 then + begin + Result := False; + exit + end; +end; + /// Возвращает квадратный корень числа function Sqrt(Self: integer): real; extensionmethod; begin diff --git a/bin/Lib/SF.pas b/bin/Lib/SF.pas index c414e4a0b..d508be097 100644 --- a/bin/Lib/SF.pas +++ b/bin/Lib/SF.pas @@ -69,6 +69,10 @@ function Prln(Self: char): char; extensionmethod := Self.Println; function Prln(Self: boolean): boolean; extensionmethod := Self.Println; function Prln(Self: string): string; extensionmethod := Self.Println; + +function D(Self,b: integer): boolean; extensionmethod := Self mod b = 0; +function ND(Self,b: integer): boolean; extensionmethod := Self mod b <> 0; + /// Записывает в min значение x если x