diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index a13a95e62..e71b73edc 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 = "10"; public const string Build = "3"; - public const string Revision = "3626"; + public const string Revision = "3627"; 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 ea92fb5d6..359b742e2 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=3 -%REVISION%=3626 %MINOR%=10 +%REVISION%=3627 +%COREVERSION%=3 %MAJOR%=3 diff --git a/InstallerSamples/WhatsNew/3_10_4/InRange.pas b/InstallerSamples/WhatsNew/3_10_4/InRange.pas new file mode 100644 index 000000000..fb408e993 --- /dev/null +++ b/InstallerSamples/WhatsNew/3_10_4/InRange.pas @@ -0,0 +1,12 @@ +begin + // Поведение изменено!! Теперь диапазон [6,2] считается пустым + 5.InRange(6,2).Println; + + // Универсальная InRange. Должен поддерживаться интерфейс IEnumerable + InRange(5,2,6).Println; + + var dt1 := DateTime.Create(2025,04,16); + var dt2 := DateTime.Create(2025,04,29); + var dt3 := DateTime.Now; + InRange(dt2,dt1,dt3).Println; +end. \ No newline at end of file diff --git a/InstallerSamples/WhatsNew/3_10_4/IsOrdered1.pas b/InstallerSamples/WhatsNew/3_10_4/IsOrdered1.pas index 876578098..c7890adf8 100644 --- a/InstallerSamples/WhatsNew/3_10_4/IsOrdered1.pas +++ b/InstallerSamples/WhatsNew/3_10_4/IsOrdered1.pas @@ -19,5 +19,5 @@ begin leaderboard := leaderboard.OrderByDescending(p -> p.Points).ToArray; Println(leaderboard); if leaderboard.IsOrderedByDescending(p -> p.Points) then - Println('Теперь рейтинг составлен неверно!'); + Println('Теперь рейтинг составлен верно!'); end. \ No newline at end of file diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Common subroutines.html b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Common subroutines.html index 37c86e028..e3a821fd8 100644 --- a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Common subroutines.html +++ b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Common subroutines.html @@ -4,6 +4,8 @@ + + @@ -34,6 +36,10 @@
         1 procedure Inc(var e: ; n: integer);
         n +function InRange<T>(val, a, b: T): boolean; where T: IComparable<T>; +
         True, val a b (a ? val ? b) +function ObjectToString(obj: object): string; +
         function Ord(a: ): ;
         a function Ord(a: ): integer; diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for array of T.html b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for array of T.html index 3f4752ae9..4fcf82e86 100644 --- a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for array of T.html +++ b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for array of T.html @@ -17,6 +17,10 @@ + + + + @@ -97,6 +101,22 @@
         , function Indices<T>(Self: array of T; cond: (T,integer) ->boolean): sequence of integer;
         , +function IsOrdered<T>(self: array of T): boolean; where T: IComparable<T>; +
        , +function IsOrdered<T>(self: array of T; comparer: IComparer<T>): boolean; +
        , , comparer +function IsOrderedBy<T, TKey>(self: array of T; keySelector: T -> TKey): boolean; +
        , +function IsOrderedBy<T, TKey>(self: array of T; keySelector: T -> TKey; +
        , +function IsOrderedByDescending<T, TKey>(self: array of T; keySelector: T -> TKey): boolean; +
        , +function IsOrderedByDescending<T, TKey>(self: array of T; keySelector: T -> TKey; +
        , +function IsOrderedDescending<T>(self: array of T): boolean; where T: IComparable<T>; +
        , +function IsOrderedDescending<T>(self: array of T; comparer: IComparer<T>): boolean; +
        , , comparer function LastIndexMax<T>(Self: array of T; index: integer): integer; where T: IComparable<T>;
         [0,index-1] function LastIndexMax<T>(Self: array of T): integer; where T: IComparable<T>; diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for char.html b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for char.html index ee7f1b760..ee1351dce 100644 --- a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for char.html +++ b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for char.html @@ -18,7 +18,7 @@ function Code(Self: char): integer;
         Unicode function InRange(Self: char; a,b: char): boolean; -
         True +
         True [a,b] function IsDigit(Self: char);
         function IsLetter(Self: char): boolean; diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for integer.html b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for integer.html index a8498bf5b..966c779c7 100644 --- a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for integer.html +++ b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for integer.html @@ -35,7 +35,7 @@ function Downto(Self: integer; n: integer): sequence of integer;
         n function InRange(Self: integer; a,b: integer): boolean; -
         True +
         True [a,b] function IsEven(Self: integer): boolean;
        , function IsOdd(Self: integer): boolean; diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for real.html b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for real.html index 7c67ee22b..234c3eafb 100644 --- a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for real.html +++ b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for real.html @@ -16,7 +16,7 @@

real

+
         True [a,b] +
         True [a, b] + + + + + + + + +
         True [a,b] ( )
function Between(Self: real; a, b: real): boolean; -
         True
function Ceil(Self: real): integer;
         ,
function Clamp(Self: real; bottom,top: real): real; @@ -28,7 +28,7 @@
function Floor(Self: real): integer;
         ,
function InRange(Self: real; a,b: real): boolean; -
         True
function Round(Self: real): integer;
         ,
function Round(Self: real; digits: integer): real; diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for sequence of T.html b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for sequence of T.html index 64ecb8cb7..d608f371d 100644 --- a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for sequence of T.html +++ b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for sequence of T.html @@ -9,6 +9,10 @@ + + + + @@ -106,6 +110,22 @@
        
function Interleave<T>(Self: sequence of T; a, b, c: sequence of T): sequence of T;
        
function IsOrdered<T>(self: sequence of T; comparer: IComparer<T>): boolean; +
        , , comparer
function IsOrdered<T>(self: sequence of T): boolean; where T: IComparable<T>; +
        ,
function IsOrderedBy<T, TKey>(self: sequence of T; keySelector: T -> TKey; +
        , ,
function IsOrderedBy<T, TKey>(self: sequence of T; keySelector: T -> TKey): boolean; +
        ,
function IsOrderedByDescending<T, TKey>(self: sequence of T; keySelector: T -> TKey; +
        , ,
function IsOrderedByDescending<T, TKey>(self: sequence of T; keySelector: T -> TKey): boolean; +
        ,
function IsOrderedDescending<T>(self: sequence of T): boolean; where T: IComparable<T>; +
        ,
function IsOrderedDescending<T>(self: sequence of T; comparer: IComparer<T>): boolean; +
        , , comparer
function JoinToString<T>(Self: sequence of T; delim: string): string;
         , , delim
function JoinToString<T>(Self: sequence of T): string; diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for string.html b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for string.html index 12376ee54..71eac754e 100644 --- a/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for string.html +++ b/PABCNetHelp/LangGuide/PABCSystemUnit/Files/Extension methods for string.html @@ -35,7 +35,7 @@
function IndicesOf(Self, SubS: string; overlay: boolean := False): sequence of integer;
         overlay ,
function InRange(Self: string; a, b: string): boolean; -
         True
function Inverse(Self: string): string;
        
function IsInteger(Self: string): boolean; diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index fe50ca55c..5bc2b1dca 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.10.3.3626 +3.10.3.3627 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 535beba0d..3f4347ff8 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.10.3.3626' +!define VERSION '3.10.3.3627' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 8934b4964..1eeb615f3 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -2334,6 +2334,8 @@ function Pred(x: uint64): uint64; ///-- function Pred(x: boolean): boolean; +/// Возвращает True, если значение val находится между a и b включительно (a ≤ val ≤ b) +function InRange(val, a, b: T): boolean; where T: IComparable; /// Меняет местами значения двух переменных procedure Swap(var a, b: T); /// Возвращает True, если достигнут конец строки @@ -2347,6 +2349,9 @@ function SeekEoln: boolean; /// Возвращает аргумены командой строки, с которыми была запущена программа function CommandLineArgs: array of string; +/// Преобразует объект в строковое представление +function ObjectToString(obj: object): string; + // ----------------------------------------------------- //>> Подпрограммы для работы с динамическими массивами # Subroutines for array of T // ----------------------------------------------------- @@ -2917,9 +2922,6 @@ function RuntimeInitialize(kind: byte; variable: object): object; ///Вычисление размера типа на этапе выполнения function GetRuntimeSize: integer; -/// Преобразует объект в строковое представление -function ObjectToString(obj: object): string; - function IsUnix: boolean; ///-- function ExecuteAssemlyIsDll: boolean; @@ -10682,6 +10684,12 @@ begin Result := char(integer(x)-n); end; +/// Возвращает True, если значение val находится между a и b включительно (a ≤ val ≤ b) +function InRange(val, a, b: T): boolean; where T: IComparable; +begin + Result := (val.CompareTo(a) >= 0) and (val.CompareTo(b) <= 0); +end; + procedure Swap(var a, b: T); begin var v := a; @@ -14195,10 +14203,10 @@ begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если значение находится в диапазоне [a,b] function InRange(Self: integer; a,b: integer): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; ///-- @@ -14297,16 +14305,16 @@ end; // ----------------------------------------------------- //>> Методы расширения типа real # Extension methods for real // ----------------------------------------------------- -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если значение находится в диапазоне [a,b] function Between(Self: real; a, b: real): boolean; extensionmethod; begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если значение находится в диапазоне [a, b] function InRange(Self: real; a,b: real): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; /// Возвращает квадратный корень числа @@ -14412,10 +14420,10 @@ begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если символ находится в диапазоне [a,b] function InRange(Self: char; a,b: char): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; /// Предыдущий символ @@ -14485,10 +14493,10 @@ begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если строка находится в диапазоне [a,b] (лексикографическое сравнение) function InRange(Self: string; a, b: string): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; /// Считывает целое из строки начиная с позиции from и устанавливает from за считанным значением diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 8934b4964..1eeb615f3 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -2334,6 +2334,8 @@ function Pred(x: uint64): uint64; ///-- function Pred(x: boolean): boolean; +/// Возвращает True, если значение val находится между a и b включительно (a ≤ val ≤ b) +function InRange(val, a, b: T): boolean; where T: IComparable; /// Меняет местами значения двух переменных procedure Swap(var a, b: T); /// Возвращает True, если достигнут конец строки @@ -2347,6 +2349,9 @@ function SeekEoln: boolean; /// Возвращает аргумены командой строки, с которыми была запущена программа function CommandLineArgs: array of string; +/// Преобразует объект в строковое представление +function ObjectToString(obj: object): string; + // ----------------------------------------------------- //>> Подпрограммы для работы с динамическими массивами # Subroutines for array of T // ----------------------------------------------------- @@ -2917,9 +2922,6 @@ function RuntimeInitialize(kind: byte; variable: object): object; ///Вычисление размера типа на этапе выполнения function GetRuntimeSize: integer; -/// Преобразует объект в строковое представление -function ObjectToString(obj: object): string; - function IsUnix: boolean; ///-- function ExecuteAssemlyIsDll: boolean; @@ -10682,6 +10684,12 @@ begin Result := char(integer(x)-n); end; +/// Возвращает True, если значение val находится между a и b включительно (a ≤ val ≤ b) +function InRange(val, a, b: T): boolean; where T: IComparable; +begin + Result := (val.CompareTo(a) >= 0) and (val.CompareTo(b) <= 0); +end; + procedure Swap(var a, b: T); begin var v := a; @@ -14195,10 +14203,10 @@ begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если значение находится в диапазоне [a,b] function InRange(Self: integer; a,b: integer): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; ///-- @@ -14297,16 +14305,16 @@ end; // ----------------------------------------------------- //>> Методы расширения типа real # Extension methods for real // ----------------------------------------------------- -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если значение находится в диапазоне [a,b] function Between(Self: real; a, b: real): boolean; extensionmethod; begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если значение находится в диапазоне [a, b] function InRange(Self: real; a,b: real): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; /// Возвращает квадратный корень числа @@ -14412,10 +14420,10 @@ begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если символ находится в диапазоне [a,b] function InRange(Self: char; a,b: char): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; /// Предыдущий символ @@ -14485,10 +14493,10 @@ begin Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); end; -/// Возвращает True если значение находится между двумя другими +/// Возвращает True если строка находится в диапазоне [a,b] (лексикографическое сравнение) function InRange(Self: string; a, b: string): boolean; extensionmethod; begin - Result := (a <= Self) and (Self <= b) or (b <= Self) and (Self <= a); + Result := (a <= Self) and (Self <= b); end; /// Считывает целое из строки начиная с позиции from и устанавливает from за считанным значением diff --git a/bin/PascalABCNET.chm b/bin/PascalABCNET.chm index 50e39cae7..e318660c7 100644 Binary files a/bin/PascalABCNET.chm and b/bin/PascalABCNET.chm differ