Can I index list or map like clojure? #2648
-
In Clojure, collections can be accessed by calling them as functions, which is useful in scientific computing. For example: (let [a [1 2 3]] (a 0)) ; => 1 (vector is callable) while in hy, i get: => (let [a [1 2 3]] (a 0))
Traceback (most recent call last):
File "stdin-62456786056834b119202f5270ca01477754a147", line 1, in <module>
(let [a [1 2 3]] (a 0))
TypeError: 'list' object is not callable This syntax doesn't seem to be supported in Hy. Is this an intentional design decision? If so, does it mean this style is discouraged in Hy? This feature is quite convenient for numerical workflows, so I'm curious about the rationale behind the difference. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not from us, because this has nothing to do with Hy: this is just Python semantics. None of Python's built-in data structures are callable, but you can make always subclass one to make a callable version. |
Beta Was this translation helpful? Give feedback.
Not from us, because this has nothing to do with Hy: this is just Python semantics. None of Python's built-in data structures are callable, but you can make always subclass one to make a callable version.