From bb6cc4325012064bb2fb22ee7d102b0aa5415040 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Thu, 22 Jan 2026 13:23:35 +0300 Subject: [PATCH] =?UTF-8?q?SPython=20=D1=81=D1=82=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D0=BD=D0=B0=D1=8F=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8?= =?UTF-8?q?=D0=BE=D1=82=D0=B5=D0=BA=D0=B0=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=87=D1=83=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/Lib/PABCSystem.pas | 2 +- bin/Lib/SPython/SPythonSystem.pas | 32 +++++++++++++++++++++++++--- bin/Lib/SPython/SPythonSystemPys.pys | 5 ++++- 3 files changed, 34 insertions(+), 5 deletions(-) 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);