(declare storage)
(defn initialize-storage []) ((def storage
(make-array Integer/TYPE 3 3))
(for [ i (range 1 3 )
j (range 1 3 )]
(aset (aget storage i) j 100)
)
(use 'clojure.pprint)
(pprint storage)
)
I get the below
ClassCastException [[I cannot be cast to clojure.lang.IFn clojure.lang.Var.fn (Var.java:378)
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
The idea is to set all the values to 100
I suspect my usage in a 2-d array context of aset is not correct but that was what i got after a fair few hours of searching.
Edit::
(use 'clojure.pprint)
(defn initialize-storage []) ((def storage
(make-array Integer/TYPE 3 3))
(for [ i (range 1 3 )
j (range 1 3 )]
(aset-int storage i j 100))
(pprint storage))
Now, that I have set my storage. I want to have another function, which will call this function and then proceed to do other tasks. But I get an exception that cannot find initialise-storage
.
How does having a namespace help in this regard? Are the functions aware of each other's presence, or do we need to make them public and expose? Should all of these be inside the namespace? Then if where do i put the (def ..), since that throws an exception as well ?