From: Brendan Hansen Date: Mon, 21 Sep 2020 03:06:59 +0000 (-0500) Subject: added math functions X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=ae2b16d9fdd3f9a5d988a90d2aee254b32e769f2;p=onyx.git added math functions --- diff --git a/core/math.onyx b/core/math.onyx index 9c222850..2e7e76a1 100644 --- a/core/math.onyx +++ b/core/math.onyx @@ -46,4 +46,14 @@ cos :: proc (t_: f32) -> f32 { res += 1.0f; return res; -} \ No newline at end of file +} + +max_poly :: proc (a: $T, b: T) -> T { + if a >= b do return a; + return b; +} + +min_poly :: proc (a: $T, b: T) -> T { + if a <= b do return a; + return b; +} diff --git a/core/string.onyx b/core/string.onyx index 0603bf6c..88766ae5 100644 --- a/core/string.onyx +++ b/core/string.onyx @@ -78,6 +78,25 @@ string_contains :: proc (str: string, c: u8) -> bool { return false; } +// string_compare :: proc (str1: string, str2: string) -> i32 { +// if str1.count != str2.count do return str1.count - str2.count; +// +// i := 0; +// while i < str1.count && str1[i] == str2[i] do i += 1; +// +// if i == str1.count do return 0; +// return ~~(str1[i] - str2[i]); +// } + +string_equal :: proc (str1: string, str2: string) -> bool { + if str1.count != str2.count do return false; + while i := 0; i < str1.count { + if str1[i] != str2[i] do return false; + i += 1; + } + return true; +} + string_strip_leading_whitespace :: proc (str: ^string) { while true do switch str.data[0] { case #char " ", #char "\t", #char "\n", #char "\r" { diff --git a/onyx b/onyx index 068a56a1..1b5c8360 100755 Binary files a/onyx and b/onyx differ