hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

strcmp.ha (406B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 type string = struct {
      5 	data: *[*]u8,
      6 	length: size,
      7 	capacity: size,
      8 };
      9 
     10 export fn strcmp(_a: str, _b: str) bool = {
     11 	if (len(_a) != len(_b)) {
     12 		return false;
     13 	};
     14 	let a = (&_a: *string).data, b = (&_b: *string).data;
     15 	for (let i = 0z; i < len(_a); i += 1) {
     16 		if (a[i] != b[i]) {
     17 			return false;
     18 		};
     19 	};
     20 	return true;
     21 };