Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum > General > > "list manipulation ?"

Post Reply:
Name:
Email Address:

Please send email when my message is replied to.

Url (optional):
Subject:
Message: view original message?
Attachment (optional):
Please answer this:1+1 =



Original Message (ID '549141') By Peter Pein:
Hi, another Approach (if 'b,c,d' is not at the same place in each sublist) would be: (* construct input *) In[1]:= list = NestList[RotateLeft, ToExpression /@ CharacterRange["a", "g"], 6] Out[1]= {{a, b, c, d, e, f, g}, {b, c, d, e, f, g, a}, {c, d, e, f, g, a, b}, {d, e, f, g, a, b, c}, {e, f, g, a, b, c, d}, {f, g, a, b, c, d, e}, {g, a, b, c, d, e, f}} (* distinguishable replacements *) In[2]:= repl = Array[p[#1] &, {7, 1}] Out[2]= {{p[1]}, {p[2]}, {p[3]}, {p[4]}, {p[5]}, {p[6]}, {p[7]}} (* the replacement-function for one sublist: *) In[3]:= f[l1_List, l2_List, seq___] := l1 /. {start___, seq, rest___} :> {start, Sequence @@ l2, rest} (* apply that func. to the input(s)*) In[4]:= MapThread[f[#1, #2, b, c, d] &, {list, repl}] Out[4]= {{a, p[1], e, f, g}, {p[2], e, f, g, a}, {c, d, e, f, g, a, b}, {d, e, f, g, a, b, c}, {e, f, g, a, p[5]}, {f, g, a, p[6], e}, {g, a, p[7], e, f}} Peter