halgari/clojure-py — pull request #143 by schuster-rainer (2012-10-31 23:12:16+00:00)
Title: bug-fix: ArrayChunk attribute nth not implemented

I tried to implement euler problem 1 and used a (range 1000) consumed by filter which in turn uses the nth attribute. I searched for .nth and found that map-indexed uses it too. range does create an ArrayChunk.

The java source implements clojure.lang.Indexed where nth is defined as member (part ot the IChunk implementation). The count member func is not used in core, so this should be fine.
https://github.com/clojure/clojure/blob/master/src/clj/clojure/gvec.clj

filter and map-indexed are using the nth member function. ArrayChunk e.g. created by range doesn't implement it and both funcs are implemented before nth is defined

Therefore using declare is not an option. I simply copied the implementation of \__getitem\__ to nth. I've added a test case at the end of core-test.clj.

Fell free to suggest improvements to the solution.