RosettaCodeData/Task/Binary-search/Tcl/binary-search-2.tcl
2023-07-01 13:44:08 -04:00

8 lines
206 B
Tcl

proc binarySearch {lst x} {
set idx [lsearch -sorted -exact $lst $x]
if {$idx == -1} {
puts "element $x not found in list"
} else {
puts "element $x found at index $idx"
}
}