lean4-htt/tests/lean/binsearch.lean
Leonardo de Moura ed3c95f892 chore: fix tests
2019-10-27 18:29:51 -07:00

14 lines
439 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def mkAssocArray : Nat → Array (Nat × Bool) → Array (Nat × Bool)
| 0, as => as
| i+1, as => mkAssocArray i (as.push (i, i % 2 == 0))
def tst (n : Nat) : IO Unit :=
do
let as := mkAssocArray n Array.empty;
IO.println as;
let as := as.qsort (fun a b => a.1 < b.1);
(2*n).forM $ fun i => do
let entry := as.binSearch (i, false) (fun a b => a.1 < b.1);
IO.println (">> " ++ toString i ++ " ==> " ++ toString entry)
#eval tst 10