Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. )
  6.  
  7. var sorted_a = []int{1, 3, 9, 99, 999, 12458, 94492, 938485, 5555555}
  8.  
  9. func main() {
  10.  
  11. searcher := func(slice []int, target int) {
  12. middle := len(slice) / 2
  13.  
  14. fmt.Printf("middle: %v\n", middle)
  15.  
  16. if middle == 0 {
  17. return
  18. }
  19.  
  20. searcher(slice[middle:], target)
  21. searcher(slice[:middle], target)
  22. }
  23.  
  24. searcher(sorted_a, 9)
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement