Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
18
Task/Binary-search/Bruijn/binary-search.bruijn
Normal file
18
Task/Binary-search/Bruijn/binary-search.bruijn
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
:import std/Combinator .
|
||||
:import std/Math .
|
||||
:import std/List .
|
||||
:import std/Option .
|
||||
|
||||
binary-search [y [[[[[2 <? 3 none go]]]]] (+0) --(∀0) 0]
|
||||
go [compare-case eq lt gt (2 !! 0) 1] /²(3 + 2)
|
||||
eq some 0
|
||||
lt 5 4 --0 2 1
|
||||
gt 5 ++0 3 2 1
|
||||
|
||||
# example using sorted list of x^3, x=[-50,50]
|
||||
find [[map-or "not found" [0 : (1 !! 0)] (binary-search 0 1)] lst]
|
||||
lst take (+100) ((\pow (+3)) <$> (iterate ++‣ (-50)))
|
||||
|
||||
:test (find (+100)) ("not found")
|
||||
:test ((head (find (+125))) =? (+55)) ([[1]])
|
||||
:test ((head (find (+117649))) =? (+99)) ([[1]])
|
||||
Loading…
Add table
Add a link
Reference in a new issue