Начал исправлять старые примеры

This commit is contained in:
Mikhalkovich Stanislav 2025-10-12 20:42:19 +03:00
parent 0c4c029bef
commit 0c4b28dcfe
14 changed files with 482 additions and 123 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "11";
public const string Build = "0";
public const string Revision = "3666";
public const string Revision = "3669";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=3666
%MINOR%=11
%REVISION%=3669
%COREVERSION%=0
%MAJOR%=3

View file

@ -1,10 +1,8 @@
// Пример иллюстрирует использование знака "&" для снятия атрибута ключевого слова
var
&begin,&end: integer;
i: integer;
begin
var &begin,&end: integer;
&begin := 1;
&end := 2;
var t: System.Type := &begin.GetType; // в System.Type использовать & не надо

View file

@ -1,7 +1,7 @@
// Пример иллюстрирует использование знака "&" для явного указания шаблонного типа подпрограммы
function GetDefault<T>: T :=
default(T);
default(T);
type
GenericType<T> = class
@ -10,8 +10,7 @@ type
end;
begin
// var o := GetDefault<byte>; //Ошибка: Встречено ';', а ожидалось выражение
// var o := GetDefault<byte>; //Ошибка: Встречено ';', а ожидалось выражение
// компилятор не отличает знак сравнения < от открытия угловой скобки
// и поэтому видит эту строчку как "(GetDefault < byte) > ;"
// ";" там оказывается неожиданно, потому что компилятор ожидал ещё какое то выражение для сравнения

View file

@ -1,17 +1,14 @@
// Присваивания += -= *= /=
var
i: integer;
r: real;
// Присваивания += -= *= /=
begin
i := 1;
var i: integer := 1;
writeln('i := 1; i = ',i);
i += 2; // Увеличение на 2
writeln('i += 2; i = ',i);
i *= 3; // Умножение на 3
writeln('i *= 3; i = ',i);
writeln;
r := 6;
var r: real := 6;
writeln('r := 6; r = ',r);
r /= 2;
writeln('r /= 2; r = ',r);

View file

@ -1,10 +1,10 @@
// Автоопределение типа переменной
// Автоопределение типа переменной
// Описание переменной в заголовке цикла for
begin
var x := 2;
for var i:=1 to 10 do
begin
write(x,' ');
Print(x);
x += 2;
end;
end.

View file

@ -1,11 +1,11 @@
// Перемена местами значений двух переменных с использованием третьей
var x,y: real;
// Перемена местами значений двух переменных с использованием третьей
begin
write('Введите x,y: ');
readln(x,y);
var v: real := x; // вспомогательная переменная
var (x,y) := ReadReal2('Введите x,y:');
var v := x; // вспомогательная переменная
x := y;
y := v;
writeln('Новые значения x,y: ',x,' ',y);
Println($'Новые значения x,y: {x} {y}');
end.

View file

@ -1,22 +1,19 @@
// Пример иллюстрирует возможности оператора foreach
var
a: array [1..5] of integer := (1,3,5,7,9);
s: set of integer;
l: List<integer>;
begin
var a: array of integer := [1,3,5,7,9];
Write('foreach по обычному массиву: ':35);
foreach x: integer in a do
Print(x);
Println;
s := [2..5,10..14];
var s: set of integer := [2..5,10..14];
Write('foreach по множеству: ':35);
foreach var x in s do
Print(x);
Println;
l := new List<integer>;
var l := new List<integer>;
l.Add(7); l.Add(2); l.Add(5);
Write('foreach по динамическому массиву: ':35);
foreach var x in l do

View file

@ -1,4 +1,4 @@
/// Вывод с помощью Print
/// Вывод с помощью Print - данные разделяются пробелами
begin
Print(1,2,3)
end.

View file

@ -1,5 +1,5 @@
// При работе с вещественными числами невозможно получить ошибку выполнения
// При работе с вещественными числами невозможно получить ошибку выполнения
begin
writeln(1/0);
writeln(sqrt(-1));
Println(1/0); // Infinity
Println(Sqrt(-1)); // Not A Number
end.

View file

@ -1 +1 @@
3.11.0.3666
3.11.0.3669

View file

@ -1 +1 @@
!define VERSION '3.11.0.3666'
!define VERSION '3.11.0.3669'

View file

@ -3,7 +3,7 @@ unit SPythonHidden;
interface
// uses PABCSystem;
uses SPythonSystem;
function !Floor(x : real) : integer;
@ -14,8 +14,36 @@ function !FloorMod(x: real; y: real): real;
type !UnknownType = class
end;
// TODO: Перенести в SPythonSystemPys следующие методы
function list<T>(sq: sequence of T): SPythonSystem.list<T>;
function list<K, V>(d : dict<K, V>) : SPythonSystem.list<K>;
function &set<T>(sq: sequence of T): &set<T>;
function &set(): empty_set;
function dict<TKey, TVal>(params pairs: array of (TKey, TVal)): dict<TKey, TVal>;
function dict<TKey, TVal>(seqOfPairs: IEnumerable<System.Tuple<TKey, TVal>>) : dict<TKey, TVal>;
implementation
function list<T>(sq: sequence of T): SPythonSystem.list<T> := new SPythonSystem.list<T>(sq);
function list<K, V>(d : dict<K, V>) : SPythonSystem.list<K> := new SPythonSystem.list<K>(d.keys());
function &set<T>(sq: sequence of T): &set<T>;
begin
Result := new &set<T>(sq);
end;
function &set(): empty_set := new empty_set;
function dict<TKey, TVal>(params pairs: array of (TKey, TVal)): dict<TKey, TVal> := new dict<TKey, TVal>(pairs);
function dict<TKey, TVal>(seqOfPairs: sequence of (TKey, TVal)): dict<TKey, TVal> := new dict<TKey, TVal>(seqOfPairs);
function !Floor(x : real) : integer := PABCSystem.Floor(x);
function !FloorDiv(x: real; y: real): integer := PABCSystem.Floor(x / y);

View file

@ -17,6 +17,7 @@ function input(): string;
function input(s: string): string;
///-
type kwargs_gen<T> = class
public !kwargs: Dictionary<string, T>
:= new Dictionary<string, T>();
@ -50,10 +51,6 @@ function filter<T>(cond: T -> boolean; s: sequence of T): sequence of T;
function sorted<T>(s: sequence of T; reverse: boolean := false): sequence of T;
function sorted<T,T1>(s: sequence of T; key: T -> T1; reverse: boolean := false): sequence of T;
function __NewSetCreatorInternal<T>(params a: array of T): NewSet<T>;
procedure clear<T>(var st: set of T);
function int(val: string): integer;
function int(val: real): integer;
@ -102,18 +99,395 @@ function abs(x: real): real;
// function floor(x: real): real;
type list<T> = class(IEnumerable<T>)
private
wrappee : PABCSystem.List<T>;
constructor Create(l : PABCSystem.List<T>) := wrappee := l;
function GetItem(ind : integer) : T := wrappee[ind];
procedure SetItem(ind : integer; newItem : T) := wrappee[ind] := newItem;
public
static function operator implicit(l : PABCSystem.List<T>) : list<T> := new list<T>(l);
constructor Create() := wrappee := new PABCSystem.List<T>();
constructor Create(capacity : integer) := wrappee := new PABCSystem.List<T>(capacity);
constructor Create(collection : sequence of T) := wrappee := new PABCSystem.List<T>(collection);
property ByIndex[ind : integer] : T read GetItem write SetItem; default;
///--
property !count : integer read wrappee.Count;
procedure append(item : T) := wrappee.Add(item);
procedure extend(seq : sequence of T) := wrappee.AddRange(seq);
procedure clear() := wrappee.Clear();
procedure insert(index : integer; item : T) := wrappee.Insert(index, item);
procedure remove(item : T);
begin
if not wrappee.Remove(item) then
raise new System.ArgumentException($'ValueError: {item} is not in list');
end;
function pop() : T;
begin
var lastIndex := wrappee.Count - 1;
Result := wrappee[lastIndex];
wrappee.RemoveAt(lastIndex);
end;
function pop(index : integer) : T;
begin
Result := wrappee[index];
wrappee.RemoveAt(index);
end;
function index(item : T) : integer := index(item, 0, wrappee.Count);
function index(item : T; start : integer) : integer := index(item, start, wrappee.Count);
function index(item : T; start : integer; &end : integer) : integer;
begin
Result := wrappee.IndexOf(item, start, &end - start);
if Result = -1 then
raise new System.ArgumentException($'ValueError: {item} is not in list');
end;
function count(item : T) : integer;
begin
var comparer := System.Collections.Generic.EqualityComparer&<T>.Default;
Result := 0;
for var i := 0 to wrappee.Count - 1 do
begin
if comparer.Equals(wrappee[i], item) then
Result += 1;
end;
end;
procedure sort() := wrappee.Sort();
procedure sort(reverse : boolean) := wrappee.OrderByDescending(x -> x);
procedure sort<TKey>(key : T -> TKey) := wrappee.OrderBy(key);
procedure sort<TKey>(key : T -> TKey; reverse : boolean) := wrappee.OrderByDescending(key);
procedure reverse() := wrappee.Reverse();
function copy() : list<T> := new list<T>(wrappee.ToList());
function GetEnumerator() : IEnumerator<T> := wrappee.GetEnumerator();
function System.Collections.IEnumerable.GetEnumerator() : System.Collections.IEnumerator := GetEnumerator();
end;
type &set<T> = record(IEnumerable<T>)
private
wrappee : PABCSystem.HashSet<T>;
constructor Create(h : PABCSystem.HashSet<T>) := wrappee := h;
public
constructor Create() := wrappee := new PABCSystem.HashSet<T>();
constructor Create(collection : sequence of T) := wrappee := new PABCSystem.HashSet<T>(collection);
constructor Create(collection : sequence of T; comparer : PABCSystem.IEqualityComparer<T>) := wrappee := new PABCSystem.HashSet<T>(collection, comparer);
constructor Create(comparer : PABCSystem.IEqualityComparer<T>) := wrappee := new PABCSystem.HashSet<T>(comparer);
///--
property !count : integer read wrappee.Count;
procedure add(elem : T) := wrappee.Add(elem);
procedure remove(elem : T);
begin
if not wrappee.Remove(elem) then
raise new System.Collections.Generic.KeyNotFoundException('KeyError: ' + elem.ToString());
end;
procedure discard(elem : T) := wrappee.Remove(elem);
function pop() : T;
begin
if wrappee.Count = 0 then
raise new System.Collections.Generic.KeyNotFoundException('KeyError: ''pop from an empty set''');
Result := wrappee.First();
wrappee.Remove(Result);
end;
procedure clear() := wrappee.Clear();
function copy() : &set<T> := new &set<T>(wrappee.ToHashSet());
static function operator in(elem: T; Self: &set<T>): boolean;
begin
Result := Self.wrappee.Contains(elem);
end;
private
function setOperation1(op : (HashSet<T>, sequence of T) -> (); params others : array of sequence of T) : &set<T>;
begin
Result.wrappee := wrappee.ToHashSet();
foreach var seq in others do
op(Result.wrappee, seq);
end;
procedure setOperation2(op : (HashSet<T>, sequence of T) -> (); params others : array of sequence of T);
begin
foreach var seq in others do
op(wrappee, seq);
end;
public
function intersection(params others : array of sequence of T) : &set<T> := setOperation1((h1, h2) -> h1.IntersectWith(h2), others);
function union(params others : array of sequence of T) : &set<T> := setOperation1((h1, h2) -> h1.UnionWith(h2), others);
function difference(params others : array of sequence of T) : &set<T> := setOperation1((h1, h2) -> h1.ExceptWith(h2), others);
function symmetric_difference(params others : array of sequence of T) : &set<T> := setOperation1((h1, h2) -> h1.SymmetricExceptWith(h2), others);
procedure update(params others : array of sequence of T) := setOperation2((h1, h2) -> h1.UnionWith(h2), others);
procedure update(other : sequence of T) := wrappee.UnionWith(other);
procedure intersection_update(params others : array of sequence of T) := setOperation2((h1, h2) -> h1.IntersectWith(h2), others);
procedure intersection_update(other : sequence of T) := wrappee.IntersectWith(other);
procedure difference_update(params others : array of sequence of T) := setOperation2((h1, h2) -> h1.ExceptWith(h2), others);
procedure difference_update(other : sequence of T) := wrappee.ExceptWith(other);
procedure symmetric_difference_update(params others : array of sequence of T) := setOperation2((h1, h2) -> h1.SymmetricExceptWith(h2), others);
procedure symmetric_difference_update(other : sequence of T) := wrappee.SymmetricExceptWith(other);
function isdisjoint(other : sequence of T) : boolean;
function issubset(other : sequence of T) : boolean := wrappee.IsSubsetOf(other);
function issuperset(other : sequence of T) : boolean := wrappee.IsSupersetOf(other);
static function operator=(s1 : &set<T>; s2 : &set<T>) : boolean := s1.wrappee.SetEquals(s2.wrappee);
static function operator<>(s1 : &set<T>; s2 : &set<T>) : boolean := not (s1 = s2);
static function operator<=(s1 : &set<T>; s2 : &set<T>) : boolean := s1.issubset(s2);
static function operator<(s1 : &set<T>; s2 : &set<T>) : boolean := (s1 <= s2) and (s1 <> s2);
static function operator>=(s1 : &set<T>; s2 : &set<T>) : boolean := s1.issuperset(s2);
static function operator>(s1 : &set<T>; s2 : &set<T>) : boolean := (s1 >= s2) and (s1 <> s2);
static function operator or(s1 : &set<T>; s2 : &set<T>) : &set<T> := s1.union(s2);
///-
function !orEqual(other : &set<T>) : &set<T>;
begin
update(other);
Result := Self;
end;
static function operator and(s1 : &set<T>; s2 : &set<T>) : &set<T> := s1.intersection(s2);
///-
function !andEqual(other : &set<T>) : &set<T>;
begin
intersection_update(other);
Result := Self;
end;
static function operator-(s1 : &set<T>; s2 : &set<T>) : &set<T> := s1.difference(s2);
static function operator -=(var s1 : &set<T>; s2 : &set<T>) : &set<T>;
begin
s1.difference_update(s2);
end;
static function operator xor(s1 : &set<T>; s2 : &set<T>) : &set<T> := s1.symmetric_difference(s2);
///-
function !xorEqual(other : &set<T>) : &set<T>;
begin
symmetric_difference_update(other);
Result := Self;
end;
// static function operator:=(var s1: &set<T>; s2: &set<T>): &set<T>;
// begin
// s1.wrappee := s2.wrappee.ToHashSet();
// end;
static function operator implicit(s : HashSet<T>) : &set<T> := new &set<T>(s);
function GetEnumerator() : IEnumerator<T> := wrappee.GetEnumerator();
function System.Collections.IEnumerable.GetEnumerator() : System.Collections.IEnumerator := GetEnumerator();
end;
type dict<K, V> = class(IEnumerable<PABCSystem.KeyValuePair<K, V>>)
private
wrappee : PABCSystem.Dictionary<K, V>;
constructor Create(d : PABCSystem.Dictionary<K, V>) := wrappee := d;
function GetValue(key : K) : V := wrappee[key];
procedure SetValue(key : K; val : V) := wrappee[key] := val;
public
constructor Create() := wrappee := new PABCSystem.Dictionary<K, V>();
constructor Create(capacity : integer) := wrappee := new PABCSystem.Dictionary<K, V>(capacity);
constructor Create(comparer : PABCSystem.IEqualityComparer<K>) := wrappee := new PABCSystem.Dictionary<K, V>(comparer);
constructor Create(capacity : integer; comparer : PABCSystem.IEqualityComparer<K>) := wrappee := new PABCSystem.Dictionary<K, V>(capacity, comparer);
constructor Create(params pairs: array of (K, V));
begin
wrappee := new PABCSystem.Dictionary<K, V>();
for var i := 0 to pairs.Length - 1 do
wrappee[pairs[i].Item1] := pairs[i].Item2;
end;
constructor Create(seqOfPairs : sequence of (K, V));
begin
wrappee := new PABCSystem.Dictionary<K, V>();
foreach var p in seqOfPairs do
wrappee[p.Item1] := p.Item2;
end;
///--
property !count : integer read wrappee.Count;
property ByKey[key : K] : V read GetValue write SetValue; default;
static function operator in(key: K; Self: dict<K, V>): boolean;
begin
Result := Self.wrappee.ContainsKey(key);
end;
procedure clear() := wrappee.Clear();
function copy() : dict<K, V> := new dict<K, V>(new Dictionary<K,V>(wrappee));
static function fromkeys(sq : sequence of K; val : V := default(V)) : dict<K, V>;
begin
Result := new dict<K, V>();
foreach var key in sq do
Result[key] := val;
end;
function get(key : K; &default : V := default(V)) : V;
begin
var val : V;
if wrappee.TryGetValue(key, val) then
Result := val
else
Result := &default;
end;
function items() : sequence of KeyValuePair<K, V> := wrappee;
function keys() := wrappee.Keys;
function pop(key : K) : V;
begin
Result := wrappee[key];
wrappee.Remove(key);
end;
function pop(key : K; &default : V) : V;
begin
var val : V;
if wrappee.TryGetValue(key, val) then
begin
Result := val;
wrappee.Remove(key);
end
else
Result := &default;
end;
function popitem() : KeyValuePair<K, V>;
begin
Result := wrappee.Last();
wrappee.Remove(Result.Key);
end;
function setdefault(key : K; &default : V := default(V)) : V;
begin
var val : V;
if wrappee.TryGetValue(key, val) then
Result := val
else
begin
wrappee[key] := &default;
Result := &default;
end;
end;
procedure update(params pairs: array of (K, V));
begin
for var i := 0 to pairs.Length - 1 do
wrappee[pairs[i].Item1] := pairs[i].Item2;
end;
procedure update(seqOfPairs : sequence of (K, V));
begin
foreach var p in seqOfPairs do
wrappee[p.Item1] := p.Item2;
end;
function values() := wrappee.Values;
static function operator or(d1 : dict<K, V>; d2 : dict<K, V>) : dict<K, V>;
begin
Result := new dict<K, V>(d1.wrappee);
foreach var p in d2.wrappee do
Result[p.Key] := p.Value;
end;
static function operator implicit(d : PABCSystem.Dictionary<K, V>) : dict<K, V> := new dict<K, V>(d);
function GetEnumerator() : IEnumerator<KeyValuePair<K, V>> := wrappee.GetEnumerator();
function System.Collections.IEnumerable.GetEnumerator() : System.Collections.IEnumerator := GetEnumerator();
end;
//Standard functions with Lists
function len<T>(lst: PABCSystem.List<T>): integer;
function len<T>(st: set of T): integer;
function len<K, V>(dct: PABCSystem.Dictionary<K, V>): integer;
function len<T>(lst: list<T>): integer;
function len<T>(st: &set<T>): integer;
function len<K, V>(dct: dict<K, V>): integer;
function len<T>(arr: array of T): integer;
function len(s: string): integer;
function &set<T>(sq: sequence of T): set of T;
function &list<T>(sq: sequence of T): PABCSystem.List<T>;
// function &set<T>(sq: sequence of T): &set<T>;
function sorted<T>(lst: PABCSystem.List<T>): PABCSystem.List<T>;
function sorted<T>(lst: list<T>): list<T>;
function sum(lst: sequence of integer): integer;
@ -162,14 +536,8 @@ function CreateTuple<T1, T2, T3, T4, T5, T6, T7>(
// TUPLES END
function Dict<TKey, TVal>(params pairs: array of (TKey, TVal)): Dictionary<TKey, TVal>;
type
biginteger = PABCSystem.BigInteger;
!list<T> = PABCSystem.List<T>;
!dict<K, V> = PABCSystem.Dictionary<K, V>;
dct<K, V> = PABCSystem.Dictionary<K, V>;
!set<T> = set of T;
tuple2<T1, T2> = System.Tuple<T1, T2>;
tuple3<T1, T2, T3> = System.Tuple<T1, T2, T3>;
tuple4<T1, T2, T3, T4> = System.Tuple<T1, T2, T3, T4>;
@ -178,30 +546,30 @@ type
tuple7<T1, T2, T3, T4, T5, T6, T7> = System.Tuple<T1, T2, T3, T4, T5, T6, T7>;
empty_list = class
class function operator implicit<T>(x: empty_list): !list<T>;
class function operator implicit<T>(x: empty_list): list<T>;
begin
Result := new !list<T>();
Result := new list<T>();
end;
end;
empty_set = class
class function operator implicit<T>(x: empty_set): !set<T>;
class function operator implicit<T>(x: empty_set): &set<T>;
begin
Result := new !set<T>;
Result := new &set<T>();
end;
end;
empty_dict = class
class function operator implicit<K, V>(x: empty_dict): !dict<K, V>;
class function operator implicit<K, V>(x: empty_dict): dict<K, V>;
begin
Result := new !dict<K, V>();
Result := new dict<K, V>();
end;
end;
function !empty_list(): empty_list;
function !empty_dict(): empty_dict;
function &set(): empty_set;
implementation
@ -246,8 +614,6 @@ begin
Result := TypeName(obj)
.Replace('<', '[')
.Replace('>', ']')
.Replace('List', 'list')
.Replace('Dictionary', 'dict')
.Replace('empty_list', 'list[anytype]')
.Replace('empty_set', 'set[anytype]')
.Replace('empty_dict', 'dict[anytype]')
@ -289,17 +655,17 @@ function abs(x: integer): integer := if x >= 0 then x else -x;
function abs(x: real): real := PABCSystem.Abs(x);
function len<T>(lst: PABCSystem.List<T>): integer := lst.Count();
function len<T>(st: set of T): integer := st.Count();
function len<K, V>(dct: PABCSystem.Dictionary<K, V>): integer := dct.Count();
function len<T>(arr: array of T): integer := arr.Count();
function len<T>(lst: list<T>): integer := lst.!count;
function len<T>(st: &set<T>): integer := st.!count;
function len<K, V>(dct: dict<K, V>): integer := dct.!count;
function len<T>(arr: array of T): integer := arr.Length;
function len(s: string): integer := s.Length;
function sorted<T>(lst: PABCSystem.List<T>): PABCSystem.List<T>;
function sorted<T>(lst: list<T>): list<T>;
begin
var new_list := new PABCSystem.List<T>(lst);
new_list.sort();
Result := new_list;
var newList := lst.copy();
newList.sort();
Result := newList;
end;
function sum(lst: sequence of integer): integer := lst.sum();
@ -360,49 +726,32 @@ begin
Result := x;
end;
function !count<T>(Self: PABCSystem.List<T>; val: T): integer; extensionmethod;
function &set<T>.isdisjoint(other : sequence of T) : boolean;
begin
Result := 0;
for var i := 0 to Self.Count - 1 do
if val = Self[i] then
Result += 1;
end;
function pop<T>(Self: PABCSystem.List<T>; ind: integer): T; extensionmethod;
begin
Result := Self[ind];
Self.RemoveAt(ind);
end;
procedure add<T>(Self: set of T; val: T); extensionmethod;
begin
Self += val;
end;
procedure remove<T>(Self: set of T; val: T); extensionmethod;
begin
Self -= val;
if other = nil then
raise new System.ArgumentNullException('other', 'Null object is not iterable');
var c1 := wrappee.Count;
var c2 := other.Count();
if (c1 = 0) or (c2 = 0) then
Result := true
else
begin
if c1 >= c2 then
Result := other.All(elem -> not wrappee.Contains(elem))
else
begin
var otherSet := new HashSet<T>(other);
Result := wrappee.All(elem -> not otherSet.Contains(elem));
end;
end;
end;
function get_keys<K, V>(dct: Dictionary<K, V>):= dct.keys;
function get_values<K, V>(dct: Dictionary<K, V>):= dct.values;
function copy<T>(Self: set of T): set of T; extensionmethod;
begin
Result := Self;
end;
procedure clear<T>(var st: set of T);
begin
st := [];
end;
function __NewSetCreatorInternal<T>(params a: array of T): NewSet<T>;
begin
//Result._hs := new HashSet<T>;
Result._hs.UnionWith(a);
end;
// TUPLES BEGIN
function CreateTuple<T1, T2>(
v1: T1; v2: T2
@ -436,20 +785,10 @@ function CreateTuple<T1, T2, T3, T4, T5, T6, T7>(
// TUPLES END
function Dict<TKey, TVal>(params pairs: array of (TKey, TVal)): Dictionary<TKey, TVal>;
begin
Result := new Dictionary<TKey, TVal>();
for var i := 0 to pairs.Length - 1 do
Result.Add(pairs[i][0], pairs[i][1]);
end;
function &set<T>(sq: sequence of T): set of T;
begin
foreach var e in sq do
Result.Add(e);
end;
function &list<T>(sq: sequence of T): PABCSystem.List<T> := sq.ToList();
//function &set<T>(sq: sequence of T): &set<T>;
//begin
// Result := new &set<T>(sq);
//end;
function all(s: sequence of boolean): boolean;
begin
@ -473,14 +812,15 @@ begin
end;
end;
function ToDictionary<T, U>(Self: sequence of System.tuple<T, U>): Dictionary<T, U>; extensionmethod;
///-
function ToDictionary<T, U>(Self: sequence of System.Tuple<T, U>): dict<T, U>; extensionmethod;
begin
Result := Self.ToDictionary(x->x[0],x->x[1]);
end;
function !empty_list(): empty_list := new empty_list();
function !empty_dict(): empty_dict := new empty_dict();
function &set(): empty_set := new empty_set;
function round(val: real): integer := PABCSystem.round(val);