Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    @ticking,

    Could you rerun the benchmarks with (vec (range 1 1000))?

    Because then you'll see why O(1) is preferrable to O(n).

    Here it is:

    (----------------------------------- < AA
    | avg    | 0.0263 ms
    | min    | 0.0 ms
    | max    | 1.0 ms
    | stddev | 0.226322208751621 ms
    | total  | 267 ms
    -----------------------------------
    ----------------------------------- < A
    | avg    | 8.0E-4 ms
    | min    | 0.0 ms
    | max    | 1.0 ms
    | stddev | 0.03998599614851074 ms
    | total  | 10 ms
    -----------------------------------
    ----------------------------------- < B
    | avg    | 0.026 ms
    | min    | 0.0 ms
    | max    | 4.0 ms
    | stddev | 0.22509701656551076 ms
    | total  | 264 ms
    -----------------------------------
    ----------------------------------- < C
    | avg    | 0.0155 ms
    | min    | 0.0 ms
    | max    | 3.0 ms
    | stddev | 0.17472479181640344 ms
    | total  | 160 ms
    -----------------------------------
    nil nil nil nil)
    

    You are right!
    I missed this. In this case of course A will be much faster...

    And now I am confused :)

    So here is what we have:

    A: fastest for vectors, slowest for linked lists

    (AA: same fast for all, but much slower than A for vectors, and still slower than C)

    C: not fastest as can be for vectors, but fastest for linked lists.

    And now comes the question: What would be the most idiomatic clojure way to implement such penultimate function assuming it will live somewhere in clojure.core?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution