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–39
# Generated by tools/algo/legacy.py from the corpus: do not edit.# Two hand-written binary searches: lib/nprandom's searchsorted(side='right') and the fasta benchmark's bisect.bisect.# Element comparisons are routed through lib/algo/legacy/order.viv; nothing else changes.from algo.legacy.order import lg_le, lg_lt
# from lib/nprandom/legacy.viv: npr_lg_search#| searchsorted(u, side='right') in a non-decreasing cdf: how many entries are <= u.defnpr_lg_search(cdf:Arr, u) {
lo =0
hi =len(cdf)
while lo < hi {
mid =floor((lo + hi) /2)
iflg_le(cdf[mid], u) {
lo = mid +1
}
else {
hi = mid
}
}
return lo
}
# from study/benchmarks/viv/bg/fasta.viv: bisectdefbisect(a:Arr, x) {
lo =0
hi =len(a)
while lo < hi {
mid = (lo + hi) //2iflg_lt(x, a[mid]) {
hi = mid
}
else {
lo = mid +1
}
}
return lo
}