Neat trick! Thanks David :) On Dec 22, 11:23 am, David Nolen <dnolen.li...@gmail.com> wrote: > On Wed, Dec 22, 2010 at 1:22 PM, David Nolen <dnolen.li...@gmail.com> wrote: > > On Wed, Dec 22, 2010 at 1:14 PM, Benny Tsai <benny.t...@gmail.com> wrote: > > >> Hi Ken, > > >> > user=> (let [[x y & more] [1 2 3 4 5]] [x y more]) > >> > [1 2 (3 4 5)] > >> > user=> (let [[x y z] [1 2 3 4 5]] [x y z]) > >> > [1 2 3] > >> > user=> (let [[_ _ a b] [1 2 3 4 5]] [a b]) > >> > [3 4] > > >> > You can grab any fixed position in this way, as well as a "rest" that > >> > is the tail of the sequence past the last of such. > > >> Right, that's true. However, Marek had given two examples of Python > >> tuple unpacking, the first being: > > >> > first, *middle, last = sequence(...) > > >> Which I believe in Python 3 will bind 'first' to the first element, > >> 'last' to the last element, and 'middle' to a sequence of all the > >> elements in the middle. That last part is what I don't know how to do > >> in Clojure. > > > One way: > > > (let [[[f & m] l] ((juxt drop-last last) '[a b c d])] [f m l]) ;; [a (b c) > > c] > > > David > > Oops typo, ;; [a (b c) d] > > David
-- 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