Re: question: {a,b,c}->{{a,b},{b,c}}??

*Subject*: [mg2506] Re: question: {a,b,c}->{{a,b},{b,c}}??*From*: Christian.Jost at epc.u-psud.fr (Christian Jost)*Date*: Wed, 15 Nov 1995 07:00:07 GMT*Approved*: usenet@wri.com*Distribution*: local*Newsgroups*: wri.mathgroup*Organization*: Universite Paris-Sud XI*Sender*: daemon at wri.com ( )

In article <DHtHo7.2pr at wri.com>, "Bart van der Zwet" <B.W.v.d.Zwet at stud.tue.nl> wrote: > Hello, > > I'm working on a problem in which I have to substitute a list, > for instance {a,b,c,d} by the other list {{a,b},{b,c},{c,d}}. > I've managed to solve it for a given length of the first list, by > using the substitution-rule : > {a_,b_,c_} -> {{a,b},{b,c}} (this for a list of three elements) > I would like to find out how this can be done for a list of arbitrary > length. > Just use the Partition command (Mathematica book page 131) In[1]: Partition[{a,b,c},2,1] Out[1] {{a, b}, {b, c}} Hope that helps, Christian. Christian Jost, Universit Paris-Sud XI, Orsay, France jost at psisun.u-psud.fr