Binary search: Difference between revisions

Content added Content deleted
(Add bruijn)
Line 2,891: Line 2,891:


'''iterative''' -- almost a direct translation of the pseudocode
'''iterative''' -- almost a direct translation of the pseudocode
<syntaxhighlight lang="chapel">proc binsearch(A:[], value) {
<syntaxhighlight lang="chapel">proc binsearch(A : [], value)
{
var low = A.domain.dim(1).low;
var high = A.domain.dim(1).high;
var low = A.domain.dim(0).low;
while (low <= high) {
var high = A.domain.dim(0).high;
while (low <= high)
{
var mid = (low + high) / 2;
var mid = (low + high) / 2;


Line 2,911: Line 2,913:
{{out}}
{{out}}
4
4

=={{header|Clojure}}==
=={{header|Clojure}}==
'''Recursive'''
'''Recursive'''