On 29 August 2010 00:11, John Newman <john...@gmail.com> wrote:
> I am going to see if I can write a function that does:
>
> => (destructure [[][2]] signal)
> (5 6 7 8)

Note that the name is already taken by clojure.core/destructure, which
is the engine behind all destructuring done by Clojure macros:

user> (let [[_ [_ _ x]] signal] x)
(5 6 7 8)
user> (destructure `[[~'_ [~'_ ~'_ ~'x]] ~signal])
[vec__2102 (((1 2 3 4) (2 3 4 5) (3 4 5 6)) ((3 4 5 6) (4 5 6 7) (5 6
7 8))) _ (clojure.core/nth vec__2102 0 nil) vec__2103
(clojure.core/nth vec__2102 1 nil) _ (clojure.core/nth vec__2103 0
nil) _ (clojure.core/nth vec__2103 1 nil) x (clojure.core/nth
vec__2103 2 nil)]

Also note that if signal was built out of vectors (and not lists), you
could extract (5 6 7 8) with associative destructuring:

user> (let [{{x 2} 1} signal]
        x)
[5 6 7 8]

Sincerely,
Michał

-- 
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

Reply via email to