ref: 8317e87e7b6f9a15ff41f9f7293ef46dc208d0d7
dir: /lib/std/test/search.myr/
use std const sl = [1, 3, 5, 8, 9, 33] const main = { expect(std.lsearch(sl[:], 1, std.numcmp), `std.Some 0) expect(std.lsearch(sl[:], 33, std.numcmp), `std.Some (sl.len - 1)) expect(std.lsearch(sl[:], 5, std.numcmp), `std.Some 2) expect(std.lsearch(sl[:], 6, std.numcmp), `std.None) expect(std.lsearch(sl[:0], 6, std.numcmp), `std.None) expect(std.bsearch(sl[:], 1, std.numcmp), `std.Some 0) expect(std.bsearch(sl[:], 33, std.numcmp), `std.Some (sl.len - 1)) expect(std.bsearch(sl[:], 5, std.numcmp), `std.Some 2) expect(std.bsearch(sl[:], 6, std.numcmp), `std.None) expect(std.bsearch(sl[:0], 1, std.numcmp), `std.None) /* empty slice */ } const expect = {a, b match a | `std.None: match b | `std.Some x: std.fatal("Expected `std.None, `std.None, got `std.None, `std.Some %i\n", x) | `std.None: /* nothing */ ;; | `std.Some x: match b | `std.None: std.fatal("Expected `std.Some %i, `std.Some %i, got `std.Some %i, `std.None\n", x, x, x) | `std.Some y: if x != y std.fatal("Expected `std.Some %i, `std.Some %i, got `std.Some %i, `std.Some %i\n", x, x, x, y) ;; ;; ;; }