test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
This commit is contained in:
35
examples/basic/0018-basic-quicksort.sx
Normal file
35
examples/basic/0018-basic-quicksort.sx
Normal file
@@ -0,0 +1,35 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
quick_sort :: (items: []$T) {
|
||||
partition :: (items: []T, lo: i64, hi: i64) -> i64 {
|
||||
pivot := items[hi];
|
||||
i := lo - 1;
|
||||
j := lo;
|
||||
while j < hi {
|
||||
if items[j] < pivot {
|
||||
i += 1;
|
||||
items[i], items[j] = items[j], items[i];
|
||||
}
|
||||
j += 1;
|
||||
}
|
||||
i += 1;
|
||||
items[i], items[hi] = items[hi], items[i];
|
||||
i
|
||||
}
|
||||
|
||||
sort :: (items: []T, lo: i64, hi: i64) {
|
||||
if lo < hi {
|
||||
pi := partition(items, lo, hi);
|
||||
sort(items, lo, pi - 1);
|
||||
sort(items, pi + 1, hi);
|
||||
}
|
||||
}
|
||||
|
||||
sort(items, 0, items.len - 1);
|
||||
}
|
||||
|
||||
main :: () {
|
||||
arr : []i64 = .[333, 2, 3, 5, 2, 2, 3, 4, 5, 6, 6, 1];
|
||||
quick_sort(arr);
|
||||
print("{}\n", arr);
|
||||
}
|
||||
Reference in New Issue
Block a user