Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Created October 27, 2012 10:59
Show Gist options
  • Select an option

  • Save jbrechtel/3964280 to your computer and use it in GitHub Desktop.

Select an option

Save jbrechtel/3964280 to your computer and use it in GitHub Desktop.
nth vs last/take
clojoomba.core.runner=> (time (count (nth (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200}) 2)))
"Elapsed time: 133.896 msecs"
20
clojoomba.core.runner=> (time (count (nth (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200}) 2)))
"Elapsed time: 121.748 msecs"
20
clojoomba.core.runner=> (time (count (nth (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200}) 2)))
"Elapsed time: 113.795 msecs"
20
clojoomba.core.runner=> (time (count (last (take 2 (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200})))))
"Elapsed time: 37.522 msecs"
20
clojoomba.core.runner=> (time (count (last (take 2 (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200})))))
"Elapsed time: 39.932 msecs"
20
clojoomba.core.runner=> (time (count (last (take 2 (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200})))))
"Elapsed time: 36.178 msecs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment