MathGroup Archive 1995

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

Search the Archive

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

  • Subject: [mg2495] RE: [mg2459] question: {a,b,c}->{{a,b},{b,c}}??
  • From: jfultz ("John R. Fultz")
  • Date: Wed, 15 Nov 1995 06:58:10 GMT
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at wri.com ( )

Here's something that will do the trick...it's generalized and fast:

In[1]:= data={a,b,c,d,e};

In[2]:= modifieddata=Transpose[{Drop[data,-1],Drop[data,1]}]

Out[2]= {{a, b}, {b, c}, {c, d}, {d, e}}

John Fultz
Wolfram Research, Inc.

----------
>From: 	Bart van der Zwet[SMTP:B.W.v.d.Zwet at stud.tue.nl]
>To: mathgroup at smc.vnet.net
>Subject: 	[mg2459] question: {a,b,c}->{{a,b},{b,c}}??

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.

Yours,

Bart van der Zwet
Student Mathematics
Eindhoven University of Technology
The Netherlands
e-mail : B.W.v.d.Zwet at stud.tue.nl





  • Prev by Date: Problems with high-dimensional lists
  • Next by Date: bizarre mathematica replacement rule error
  • Previous by thread: question: {a,b,c}->{{a,b},{b,c}}??
  • Next by thread: Re: question: {a,b,c}->{{a,b},{b,c}}??