I have a working function to slice multidimensional nested vectors a la MATLAB (actually more like NumPy).
I'm using Konrad Hinsen's multi-array library (keep up the great work Konrad!). Here's the code (I'm sure it can be greatly improved and optimized): (defn nv-subvec [x & ind] (loop [v x dim 0 i ind] (let [[start end step] (first i) other (rest i)] (if (empty? other) (nv-sample v dim start end step) (recur (nv-sample v dim start end step) (inc dim) other))))) It works like this: (nv-subvec VECTOR SLICE+) where each SLICE is [STAR END STEP]. Here's a 3 x 3 matrix: (def a [[[1 2 3] [4 5 6] [7 8 9]] [[10 11 12] [13 14 15] [16 17 18]] [[19 20 21] [22 23 24] [25 26 27]]]) user=> (nv-subvec a [0 3 2] [0 2 1] [1 3 1]) [[[2 3] [5 6]] [[20 21] [23 24]]] user=> (nv-subvec a [0 3 2] [0 2 1]) [[[1 2 3] [4 5 6]] [[19 20 21] [22 23 24]]] The result is correct in both cases. Seems to work fine. Of course a lot of space for improvement. Let me know what you think. On Jan 11, 8:26 am, Konrad Hinsen <konrad.hin...@fastmail.net> wrote: > On 10 Jan 2010, at 21:39, extrackc wrote: > > > Have you looked into Incanter project? I just found out about it > > recently. "Incanter is a Clojure-based, R-like platform for > > statistical computing and graphics." http://incanter.org/ > > Incanter uses ParallelColt as its underlying matrix library. While > this is a fine library for working with matrices, it is not a > multidimensional array library. Colt arrays exist only in 1, 2, and 3 > dimensions and there are no generic (dimension-independent) operations > on array structure. > > As the huge success of Matlab has shown, a lot can be done with just > matrices and vectors, but anyone who has used an array language (such > as APL) or an equivalent library (such as Python's NumPy) will feel > constrained by such an approach. > > Konrad. -- 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