Group Abstract Group Abstract

Message Boards Message Boards

Reduce sublists in a nested list

GROUPS:
I have a list :
 {{1267, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
 {900, {String, Integer, Real, Real, Real, Real, Integer,Integer}},
 {500, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
 {1567, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
 {200, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
 {550, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
 {800, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
 {0, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
 {943, {String, Integer, Real, Real,  Real, Real, Integer, Integer}},
{0, {String, Integer, Real, Real,  Real, Real, Integer, Integer}},
{380, {String, Integer, Real, Real,  Real, Real, Integer, Integer}},
{600, {String, Integer, Real,   Real, Real, Real, Integer, Integer}},
{500, {String, Integer, Real,  Real, Real, Real, Integer, Integer}},
{490, {String, Integer, Real, Real, Real, Real, Integer, Integer}},
{190, {String, Integer,  Real, Real, Real, Real, Integer, Integer}},
{305, {String,   Integer, Real, Real, Real, Real, Integer, Integer}, 
{String,  Integer, Real, Real, Real, Real, Integer, Integer} },
{300, {String,  Integer, Real, Real, Real, Real, Integer,   Integer}},
{1000, {String, Integer, Real, Real, Real, Real,   Integer, Integer}},
{0, {String, Integer, Real, Real, Real, Real,  Integer, Integer}},
{0, {String, Integer, Real, Real, Real, Real,  Integer, Integer}},
{0, {String, Integer, Real, Real, Real, Real,  Integer, Integer}},
{0, {String, Integer, Real, Real, Real, Real,  Integer, Integer}},
{0, {String, Integer, Real, Real, Real, Real,   Integer, Integer}}}
How to create new one that has not sublists  ----
{String, Integer, Real, Real, Real, Real, Integer, Integer}
I tried this :
mi2 = Select[filestomi, Map[Head[#[[1]]] == Integer &, 3]]
but it has something missing .
POSTED BY: Artur Kotarski
Answer
11 months ago
I am not sure I understand "create new one that has not sublists ".

Do you want to eliminate the contents of the sublists so you have just
{1267, 900, 500, ..}
?

Do you want to Flatten-out the sub-sublists?
 In[9]:= Map[ Flatten, {{1267, {String, Integer, Real, Real, Real,
     Real, Integer, Integer}}, {900, {String, Integer, Real, Real,
     Real, Real, Integer, Integer}}, {500, {String, Integer, Real,
     Real, Real, Real, Integer, Integer}}, {1567, {String, Integer,
     Real, Real, Real, Real, Integer, Integer}}}]
 
 Out[9]= {{1267, String, Integer, Real, Real, Real, Real, Integer, Integer},
 {900, String, Integer, Real, Real, Real, Real, Integer, Integer},
 {500, String, Integer, Real, Real, Real, Real, Integer, Integer},
{1567, String, Integer, Real, Real, Real, Real, Integer, Integer}}
POSTED BY: Bruce Miller
Answer
11 months ago
the main list has one  sublist :{String, Integer, Real, Real, Real, Real, Integer, Integer}  in it.I want it to be rid of this sublist .Every other sublists begin with an integer
POSTED BY: Artur Kotarski
Answer
11 months ago
data /. {x_Integer, y_List, _List} :> {x, y}
data /. {x_Integer, y_List, _List} :> Sequence[]
I guess those. But it depends on your intension....
POSTED BY: Sander Huisman
Answer
11 months ago