Thanks. That does look clearer.
Dave
On Jul 27, 4:15 pm, Joost wrote:
>
> I think the main thing that's confusing here is that you're messing
> with offsets and split collections at once. At least is was confusing
> to me. :)
>
> I think for binary search (which implies random lookup is ~ O(n)
>
Dave Snowdon wrote:
> ; helper function that splits a collection into halves
> (defn halve [coll]
> (let [len (count coll), hl (- len (/ len 2))]
> [(take hl coll) (drop hl coll)]
> )
> )
>
> ; takes a value and an ordered sequence and returns the index of the value
> or -1
> (defn chop
Hi folks
I've just started teaching myself clojure and for lack of a "real" project
to use it on I've been using the "code kata" on pragprog.com as example
problems to solve.
I've implemented the binary search as described here:
http://codekata.pragprog.com/2007/01/kata_two_karate.html however I'm