This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize
for the AI-speak, we are working on rewriting it!
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.
[1]lines 1–33
# Generated by tools/algo/legacy.py from the corpus: do not edit.# The /compare page's recursive merge sort on lists.# Element comparisons are routed through lib/algo/legacy/order.viv; nothing else changes.from algo.legacy.order import lg_le
# from study/compare/recursion/merge_sort.viv: merge merge_sortdefmerge(a, b) {
out = []
i =0
j =0while i <len(a) and j <len(b) {
iflg_le(a[i], b[j]) {
out =append(out, a[i])
i +=1
}
else {
out =append(out, b[j])
j +=1
}
}
out =extend(out, a[i:])
out =extend(out, b[j:])
return out
}
defmerge_sort(xs) {
iflen(xs) <=1 {
return xs
}
mid =len(xs) //2returnmerge(merge_sort(xs[:mid]), merge_sort(xs[mid:]))
}