diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index a3c5b838d..d90aa57d0 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 = "2781"; + public const string Revision = "2783"; 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 0925067cd..3e6c8120e 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=7 -%REVISION%=2781 +%REVISION%=2783 %COREVERSION%=1 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 27ec17c43..4b9b9e4bf 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.7.1.2781 +3.7.1.2783 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 9c1428949..36f98fc54 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.7.1.2781' +!define VERSION '3.7.1.2783' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 9d32b6cff..9a9da0a12 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -11830,7 +11830,7 @@ begin Result := True; end; -/// Возвращает все перестановки +/// Возвращает все перестановки множества элементов, заданного массивом function Permutations(Self: array of T): sequence of array of T; extensionmethod; begin var a := Self; @@ -11844,6 +11844,44 @@ begin until not NextPermutation(ind); end; +/// Возвращает все частичные перестановки из n элементов по m +function Permutations(Self: array of T; m: integer): sequence of array of T; extensionmethod; +begin + Result := Self.Combinations(m).SelectMany(c->c.Permutations); +end; + + +/// Возвращает n-тую декартову степень множества элементов, заданного массивом +function Cartesian(Self: array of T; n: integer): sequence of array of T; extensionmethod; +begin + var r := new integer[n]; + var ar1 := new T[n]; + for var i:=0 to n-1 do + ar1[i] := Self[r[i]]; + yield ar1; + + var m := Self.Length; + while True do + begin + var i := n-1; + r[i] += 1; + while r[i]>=m do + begin + r[i] := 0; + i -= 1; + if i<0 then + exit; + r[i] += 1; + end; + + var ar := new T[n]; + for var j:=0 to n-1 do + ar[j] := Self[r[j]]; + yield ar; + end; +end; + + // Внутренние функции для одномерных массивов ///-- diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 4167aed22..9ced3bea4 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -7222,7 +7222,9 @@ end; function Eof(f: Text): boolean; begin - if f.sr <> nil then + if f = input then + Result := Eof + else if f.sr <> nil then Result := f.sr.EndOfStream else if f.sw <> nil then raise new IOException(GetTranslation(EOF_FOR_TEXT_WRITEOPENED)) @@ -7231,7 +7233,9 @@ end; function Eoln(f: Text): boolean; begin - if f.sr <> nil then + if f = input then + Result := Eoln + else if f.sr <> nil then Result := f.sr.EndOfStream or (f.sr.Peek = 13) or (f.sr.Peek = 10) else if f.sw <> nil then raise new IOException(GetTranslation(EOLN_FOR_TEXT_WRITEOPENED)) @@ -7240,6 +7244,11 @@ end; function SeekEof(f: Text): boolean; begin + if f = input then + begin + Result := SeekEof; + exit; + end; if f.sw <> nil then raise new IOException(GetTranslation(SEEKEOF_FOR_TEXT_WRITEOPENED)); if f.sr = nil then @@ -7257,6 +7266,11 @@ end; function SeekEoln(f: Text): boolean; begin + if f = input then + begin + Result := SeekEoln; + exit; + end; if f.sw <> nil then raise new IOException(GetTranslation(SEEKEOLN_FOR_TEXT_WRITEOPENED)); if f.sr = nil then @@ -11844,6 +11858,13 @@ begin until not NextPermutation(ind); end; +/// Возвращает все частичные перестановки из n элементов по m +function Permutations(Self: array of T; m: integer): sequence of array of T; extensionmethod; +begin + Result := Self.Combinations(m).SelectMany(c->c.Permutations); +end; + + /// Возвращает n-тую декартову степень множества элементов, заданного массивом function Cartesian(Self: array of T; n: integer): sequence of array of T; extensionmethod; begin