mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
...
This commit is contained in:
parent
a0770d4191
commit
1444c4b380
@ -58,3 +58,7 @@ Return the smallest integer value greater than or equal to `x`.
|
|||||||
### `math.sqrt(x)`
|
### `math.sqrt(x)`
|
||||||
|
|
||||||
Return the square root of `x`.
|
Return the square root of `x`.
|
||||||
|
|
||||||
|
### `math.gcd(a, b)`
|
||||||
|
|
||||||
|
Return the greatest common divisor of `a` and `b`.
|
@ -4,7 +4,7 @@ label: requests
|
|||||||
---
|
---
|
||||||
|
|
||||||
!!!
|
!!!
|
||||||
This module is experimental. To enable it, download `httplib.h` from https://github.com/yhirose/cpp-httplib and place it in the same directory as `pocketpy.h`.
|
This module is experimental. To enable it, download `httplib.h` from [here](https://github.com/yhirose/cpp-httplib) and place it in the same directory as `pocketpy.h`.
|
||||||
|
|
||||||
SSL is not supported.
|
SSL is not supported.
|
||||||
!!!
|
!!!
|
||||||
|
@ -775,6 +775,12 @@ inline void add_module_math(VM* vm){
|
|||||||
vm->bind_func<1>(mod, "floor", CPP_LAMBDA(VAR((i64)std::floor(vm->num_to_float(args[0])))));
|
vm->bind_func<1>(mod, "floor", CPP_LAMBDA(VAR((i64)std::floor(vm->num_to_float(args[0])))));
|
||||||
vm->bind_func<1>(mod, "ceil", CPP_LAMBDA(VAR((i64)std::ceil(vm->num_to_float(args[0])))));
|
vm->bind_func<1>(mod, "ceil", CPP_LAMBDA(VAR((i64)std::ceil(vm->num_to_float(args[0])))));
|
||||||
vm->bind_func<1>(mod, "sqrt", CPP_LAMBDA(VAR(std::sqrt(vm->num_to_float(args[0])))));
|
vm->bind_func<1>(mod, "sqrt", CPP_LAMBDA(VAR(std::sqrt(vm->num_to_float(args[0])))));
|
||||||
|
vm->bind_func<2>(mod, "gcd", [](VM* vm, ArgsView args) {
|
||||||
|
i64 a = CAST(i64, args[0]);
|
||||||
|
i64 b = CAST(i64, args[1]);
|
||||||
|
a = std::gcd(a, b);
|
||||||
|
return VAR(a);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void add_module_dis(VM* vm){
|
inline void add_module_dis(VM* vm){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user