slice print
This commit is contained in:
@@ -33,11 +33,7 @@ quickSort :: (items: []$T) {
|
||||
}
|
||||
|
||||
main :: () {
|
||||
arr := []s32.[1, 2, 3, 5, 2, 2, 3, 4, 5, 6, 6, 1];
|
||||
arr : []s32 = .[333, 2, 3, 5, 2, 2, 3, 4, 5, 6, 6, 1];
|
||||
quickSort(arr);
|
||||
for arr {
|
||||
if it_index > 0 { write(", "); }
|
||||
print("{}", it);
|
||||
}
|
||||
write("\n");
|
||||
print("{}\n", arr);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,17 @@ array_to_string :: (a: $T) -> string {
|
||||
concat(result, "]");
|
||||
}
|
||||
|
||||
slice_to_string :: (items: []$T) -> string {
|
||||
result := "[";
|
||||
i := 0;
|
||||
while i < items.len {
|
||||
if i > 0 { result = concat(result, ", "); }
|
||||
result = concat(result, any_to_string(field_value(items, i)));
|
||||
i += 1;
|
||||
}
|
||||
concat(result, "]");
|
||||
}
|
||||
|
||||
union_to_string :: (u: $T) -> string {
|
||||
tag := cast(s32) u;
|
||||
result := concat(".", field_name(T, tag));
|
||||
@@ -143,6 +154,7 @@ any_to_string :: (val: Any) -> string {
|
||||
case enum: result = enum_to_string(cast(type) val);
|
||||
case vector: result = vector_to_string(cast(type) val);
|
||||
case array: result = array_to_string(cast(type) val);
|
||||
case slice: result = slice_to_string(cast(type) val);
|
||||
case union: result = union_to_string(cast(type) val);
|
||||
}
|
||||
result;
|
||||
|
||||
Reference in New Issue
Block a user