lentes icon indicating copy to clipboard operation
lentes copied to clipboard

content.adoc Composition example gets "nth not supported on this type: Long" error

Open wrightmikea opened this issue 7 years ago • 0 comments

When I evaluate the composition example (using cider nrepl) I get an "nth not supported on this type: Long" error.

user> (require '[lentes.core :as l]) nil user> (def my-lens (comp l/fst l/fst (l/nth 2))) #'user/my-lens user> (def data [[0 1 2] [3 4 5]]) #'user/data user> (l/focus my-lens data) UnsupportedOperationException nth not supported on this type: Long clojure.lang.RT.nthFrom (RT.java:888) user>

Either my-lens should have one fewer l/fst function in the composed function or the data needs another level of square brackets, right?

This works for me:

user> (def my-lens2 (comp l/fst (l/nth 2))) #'user/my-lens2 user> (l/focus my-lens2 data) 2 user> (def data2 [[[0 1 2] [3 4 5]]]) #'user/data2 user> (l/focus my-lens data2) 2 user>

wrightmikea avatar Jul 20 '17 17:07 wrightmikea