Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Binary-search/Hoon/binary-search.hoon
Normal file
10
Task/Binary-search/Hoon/binary-search.hoon
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|= [arr=(list @ud) x=@ud]
|
||||
=/ lo=@ud 0
|
||||
=/ hi=@ud (dec (lent arr))
|
||||
|-
|
||||
?> (lte lo hi)
|
||||
=/ mid (div (add lo hi) 2)
|
||||
=/ val (snag mid arr)
|
||||
?: (lth x val) $(hi (dec mid))
|
||||
?: (gth x val) $(lo +(mid))
|
||||
mid
|
||||
Loading…
Add table
Add a link
Reference in a new issue