8 lines
206 B
Tcl
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"
|
|
}
|
|
}
|