## Note
If my style is wrong (i.e. not Mathematica way), please let me know. I'm happy to adjust.
## Context
I'm writing a function that look something like:
triDiagonalQ[mat_] := MapIndexed[ #1 == 0 || Abs[#2[[1]]-#2[[2]]] <= 1 &, mat, {2}] // Flatten // And @@ # &
Now, things like #2[[1]], #2[[2]] is somewhat hard to read. I'd prefer to do something like:
triDiagonalQ[mat_] := MapIndexed[ #1 == 0 || Abs[i-j] <= 1 &, mat, {2}] // Flatten // And @@ # & (* with a {i, j} <- #2 somewhere *)
## Question
Is there someway to do something like destructuring in Mathematica?
Thanks!
## Edit:
What I have in mind for "destructuring"
* http://clojure.org/special_forms
* http://java.dzone.com/articles/clojure-destructuring
* http://blog.jayfields.com/2010/07/clojure-destructuring.html
(These have nothing to do with Mathematica; they're posted mainly to demonstrated what is meant by "destructuring")