added math functions
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 21 Sep 2020 03:06:59 +0000 (22:06 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 21 Sep 2020 03:06:59 +0000 (22:06 -0500)
core/math.onyx
core/string.onyx
onyx

index 9c22285085a93fb6ab446cadca3d1fb0c083c204..2e7e76a1965c97e364c0d1c1434510f0ef9846a1 100644 (file)
@@ -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;
+}
index 0603bf6c3b236ab1882312c5d8bf7188accf0c6d..88766ae527c68a97c0f9bf7ee46818e81a3406ac 100644 (file)
@@ -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 068a56a1e19098a39e3b37a3974b448e8e6ac743..1b5c8360fdde28a21badea338c7e0b438ef66811 100755 (executable)
Binary files a/onyx and b/onyx differ