c051f5d3e7
* patterns: Rewrite most of the evaluator to mainly use polymorphism instead of just RTTI * patterns: Fixed a couple of AST memory leaks * patterns: Parse string operations correctly * patterns: Various fixes and cleanup * patterns: Implement primitive function definitions Function parameters now need to provide their type in the definition * patterns: Added function variable definition and assignment * patterns: Added remaining function statements * patterns: Added unsized and while-sized arrays * patterns: Added multi variable declarations to functions * patterns: Added std::format built-in function * patterns: Allow passing custom types to functions * patterns: Added attributes and new "format" attribute * patterns: Use libfmt for std::print instead of custom version * patterns: Remove unnecessary string compare function * pattern: Fix preprocessor directives * patterns: Fix unit tests * patterns: Added cast expression * patterns: Handle endianess in function parameters * patterns: Added casting to different endian * patterns: Added 'str' type for functions
47 lines
658 B
Raku
47 lines
658 B
Raku
namespace std::math {
|
|
|
|
fn min_u(u128 a, u128 b) {
|
|
return (a < b) ? a : b;
|
|
};
|
|
|
|
fn min_i(s128 a, s128 b) {
|
|
return (a < b) ? a : b;
|
|
};
|
|
|
|
fn min_f(double a, double b) {
|
|
return (a < b) ? a : b;
|
|
};
|
|
|
|
|
|
fn max_u(u128 a, u128 b) {
|
|
return (a > b) ? a : b;
|
|
};
|
|
|
|
fn max_i(s128 a, s128 b) {
|
|
return (a > b) ? a : b;
|
|
};
|
|
|
|
fn max_f(double a, double b) {
|
|
return (a > b) ? a : b;
|
|
};
|
|
|
|
|
|
fn abs_i(s128 value) {
|
|
return value < 0 ? -value : value;
|
|
};
|
|
|
|
fn abs_d(double value) {
|
|
return value < 0 ? -value : value;
|
|
};
|
|
|
|
|
|
fn ceil(double value) {
|
|
s128 cast;
|
|
cast = value;
|
|
|
|
return cast + 1;
|
|
};
|
|
|
|
}
|
|
|
|
std::print("{}", std::math::ceil(123.6)); |