diff --git a/PABCNetHelp/LangGuide/Types/dynamicarrays.html b/PABCNetHelp/LangGuide/Types/dynamicarrays.html index 6a9fefceb..7e54b1d67 100644 --- a/PABCNetHelp/LangGuide/Types/dynamicarrays.html +++ b/PABCNetHelp/LangGuide/Types/dynamicarrays.html @@ -96,7 +96,7 @@

var a := Arr(1,3,5,7,8);                   // array of integer
var s := Arr('Иванов','Петров','Сидоров'); // array of string
var - b := ArrFill(777,5);                   + b := ArrFill(5,777);                   // b = [777,777,777,777,777]
var r := ArrRandom(10);                    // заполнение 10 случайными целыми в диапазоне от 0 до 100 

diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 66c05b319..4ec9c9947 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -1777,7 +1777,7 @@ function Sign(x: real): integer; ///-- function Sign(x: BigInteger): integer; ///-function Abs(x: число): число; -/// Возвращает модуль числа x +/// Возвращает модуль числа function Abs(x: shortint): shortint; ///-- function Abs(x: smallint): smallint; diff --git a/bin/Lib/SPython/SPythonSystem.pas b/bin/Lib/SPython/SPythonSystem.pas index 91e4bf471..7728fe747 100644 --- a/bin/Lib/SPython/SPythonSystem.pas +++ b/bin/Lib/SPython/SPythonSystem.pas @@ -91,12 +91,25 @@ function !format(val: real; fmt: string): string; //function any(seq: sequence of T): boolean; -// Standard Math functions +//------------------------------------ +// Standard Math functions +//------------------------------------ +/// Возвращает абсолютное значение числа function abs(x: integer): integer; - +/// Возвращает абсолютное значение числа function abs(x: real): real; +/// Возвращает результат и остаток от целочисленного деления +function divmod(a,b: integer): (integer,integer); + +/// Возвращает x в степени y +function pow(x,y: real): real; +/// Возвращает x в целой степени n +function pow(x: real; n: integer): real; +/// Возвращает x в целой степени n +function pow(x: BigInteger; n: integer): BigInteger; + // function floor(x: real): real; type list = class(IEnumerable) @@ -651,10 +664,23 @@ end; //function any(seq: sequence of T): boolean := seq.Any(x -> x); -function abs(x: integer): integer := if x >= 0 then x else -x; +//------------------------------------ +// Standard Math functions +//------------------------------------ +function abs(x: integer): integer := if x >= 0 then x else -x; function abs(x: real): real := PABCSystem.Abs(x); +function divmod(a,b: integer): (integer,integer) + := (a div b, a mod b); +// divmod вещественный аналог надо реализовать на питоне бы + +function pow(x,y: real): real := PABCSystem.Power(x,y); + +function pow(x: real; n: integer): real := PABCSystem.Power(x,n); + +function pow(x: BigInteger; n: integer): BigInteger := PABCSystem.Power(x,n); + function len(lst: list): integer := lst.!count; function len(st: &set): integer := st.!count; function len(dct: dict): integer := dct.!count; diff --git a/bin/Lib/SPython/SPythonSystemPys.pys b/bin/Lib/SPython/SPythonSystemPys.pys index 7211115f9..22c0d134d 100644 --- a/bin/Lib/SPython/SPythonSystemPys.pys +++ b/bin/Lib/SPython/SPythonSystemPys.pys @@ -15,4 +15,7 @@ def print(*args: obj, **kwargs: str): if len(args) != 0: pas_print(args[len(args) - 1]) - pas_print(end) \ No newline at end of file + pas_print(end) + +#def divmod(a: int, b: int) -> (int,int) +# := (a // b, a % b);