Closed primo-ppcg closed 1 year ago
I tried it out a bit. In my limited testing it seemed fine :+1:
I wondered a bit about the case where one might want to know if some element is present. I guess once a value is returned, one could inspect the array using the returned index (taking into account the case where the index lies outside the currently valid indices).
one could inspect the array using the returned index
Seems sufficient to me, although a separate implementation could implement short circuiting. Worst and average runtime complexity would remain unchanged, though.
binary-search
andbinary-search-by
to efficiently locate a value / insert position within a sorted tuple or array. These are implemented as macros so that primitive comparators will compile directly to vm ops.insert-sorted
andinsert-sorted-by
to utilize these macros.misc.janet
has been run throughfmt/format-file
.No new tests have been added, the current tests for
insert-sorted
andinsert-sorted-by
are likely sufficient.