Hmmm... sounds like you might want to take a look at the latest development version core.matrix:
https://github.com/clojure-numerics/core.matrix You can construct nested vectors of arbitrary shape, e.g. (new-array 2 3 4 5) This creates a new 4-dimensional 2x3x4x5 matrix. core.matrix supports all different kinds of matrix types (e.g. native JBLAS matrices) but if you want to work with nested Clojure vectors you can just do: (set-current-implementation []) On Tuesday, 5 February 2013 23:03:17 UTC+8, Jim foo.bar wrote: > > Hi all, > > I 'm a bit confused with this - I'm trying to think but I can't!!! > Probably cos I've not had any food yet! > Up till now I thought I could construct matrices with 'for'...So (for [i > (range 3)] i) gives us a 1d structure (a list)... > (for [i (range 3) j (range 4)] [i j]) gives us a 2d structure (list of > vectors) > > On that basis I wrote the following little macro thinking I'd be bale to > create matrices with arbitrary dimensions: > > (defn matrix [& dim-lengths] > (let [bindings (vec (mapcat #(vector (gensym) `(range ~%)) dim-lengths)) > symbols (mapv first (partition 2 bindings)) > counts (count symbols)] > `(for ~bindings (if (< counts 1) ~symbols (first ~symbols))))) > > Now, even though this expands to the 'for' I want I'm starting to think > this is not the right approach for matrices...all I get is 2d structures > regardless of how many dimensions I pass in... > > any ideas anyone? > > Jim > > > > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.