Skip to main content
added 387 characters in body
Source Link
Alexei Boulbitch
  • 40k
  • 2
  • 48
  • 100

Try this:

pts = {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}

(*  {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}  *)

pts /. {} -> Nothing

(* {{{t1, a1, b1, c1}}, {{ti, ai, bi, ci}}}  *)

If you have there nested empty lists you will need to apply the procedure several times. For example, let your list be:

pts = {{{}}, {{{{}}}}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}};

Then the repeated application of the above rule can look as follows:

FixedPoint[ReplaceAll[#, {} -> Nothing] &, pts]

(*  {{{t1, a1, b1, c1}}, {{ti, ai, bi, ci}}}  *)

Have fun!

Try this:

pts = {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}

(*  {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}  *)

pts /. {} -> Nothing

(* {{{t1, a1, b1, c1}}, {{ti, ai, bi, ci}}}  *)

Have fun!

Try this:

pts = {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}

(*  {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}  *)

pts /. {} -> Nothing

(* {{{t1, a1, b1, c1}}, {{ti, ai, bi, ci}}}  *)

If you have there nested empty lists you will need to apply the procedure several times. For example, let your list be:

pts = {{{}}, {{{{}}}}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}};

Then the repeated application of the above rule can look as follows:

FixedPoint[ReplaceAll[#, {} -> Nothing] &, pts]

(*  {{{t1, a1, b1, c1}}, {{ti, ai, bi, ci}}}  *)

Have fun!

Source Link
Alexei Boulbitch
  • 40k
  • 2
  • 48
  • 100

Try this:

pts = {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}

(*  {{}, {}, {{t1, a1, b1, c1}}, {}, {{ti, ai, bi, ci}}}  *)

pts /. {} -> Nothing

(* {{{t1, a1, b1, c1}}, {{ti, ai, bi, ci}}}  *)

Have fun!