I have a big list that contains many 3D- chains (set of points) and for each of them a polynomial. So the structure of my list is for example

list= {{m^2 + l^2 - 1, {{x1, y1, z1}, {x2, y2, z2}, ...}}, {l^3, {{x'1, y'1, z'1}, ...}} 

and so on.

Now I want to export all chains in a separate file which have either p1 or p2 as their polynomial. So in a if-loop the syntax would be like

 list[[i]][[1]] === (p1 or p2), 
 Export["list_i.txt", multilist[[i]][[2]], "Table", "FieldSeparators" -> " "]

I want to avoid using loops, and I also don't know how to include the current value of i in the loop in the filename of the export-file.

Does anyone know how to do this without loops? Thanks a lot!

  • $\begingroup$ Have you tried Select and then Map Export on the preselected chains? $\endgroup$
    – BlacKow
    May 5, 2016 at 16:05

1 Answer 1


This might work for you:

selected = Select[list, First[#] === p1 || First[#] === p2 &];
  Export["list_" <> ToString[First@#2] <> ".txt", #1, "Table", "FieldSeparators" -> " "] &,
  selected[[All, 2]]

It would be best, however, if you had actual examples of your list and of the polynomials p1 and p2 for us to test our code on.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.