MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


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


  • Prev by Date: Re: Request for MMA benchmarks & platform comparisons
  • Next by Date: Stochastic Taylor Expansions
  • Previous by thread: Re: question: {a,b,c}->{{a,b},{b,c}}??
  • Next by thread: RE: question: {a,b,c}->{{a,b},{b,c}}??