Re: DeleteCases
- To: mathgroup at smc.vnet.net
- Subject: [mg123930] Re: DeleteCases
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Fri, 30 Dec 2011 07:10:10 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201112290754.CAA21133@smc.vnet.net>
data = {{{{0.912546, 0.1081}, -0.0206463},
{{0.186044, 0.835368}, -0.0214121},
{{0.0841709, -0.676585}, 1.59241}},
{{{-0.976965, -0.339164, -0.210989}, 2.52712},
{{0.13978, -0.995106, 0.756386}, 1.09894},
{{-0.313147, -0.432759, 0.207548}, 1.53836}}};
DeleteCases[data, {{__}, _?(Abs[#] > 1 &)}, Infinity]
{{{{0.912546, 0.1081}, -0.0206463}, {{0.186044,
0.835368}, -0.0214121}}, {}}
data /. {{__}, _?(Abs[#] > 1 &)} -> Sequence[]
{{{{0.912546, 0.1081}, -0.0206463}, {{0.186044,
0.835368}, -0.0214121}}, {}}
DeleteCases[#, _?(Abs[Last[#]] > 1 &)] & /@ data
{{{{0.912546, 0.1081}, -0.0206463}, {{0.186044,
0.835368}, -0.0214121}}, {}}
Cases[#, _?(Abs[Last[#]] <= 1 &)] & /@ data
{{{{0.912546, 0.1081}, -0.0206463}, {{0.186044,
0.835368}, -0.0214121}}, {}}
Select[#, Abs[Last[#]] <= 1 &] & /@ data
{{{{0.912546, 0.1081}, -0.0206463}, {{0.186044,
0.835368}, -0.0214121}}, {}}
Pick[#, #[[All, -1]], _?(Abs[#] <= 1 &)] & /@ data
{{{{0.912546, 0.1081}, -0.0206463}, {{0.186044,
0.835368}, -0.0214121}}, {}}
% == %% == %%% == %%%% == %%%%% == %%%%%%
True
Bob Hanlon
On Thu, Dec 29, 2011 at 2:54 AM, umberto <umberto.prisco at unina.it> wrote:
> Dear All,
>
> I have tables of this type:
>
> {{{{0.912546, 0.1081}, -0.0206463}, {{0.186044, 0.835368}, -0.0214121},
> {{0.0841709, -0.676585}, 1.59241}}, {{{-0.976965, -0.339164, -0.210989},
> 2.52712}, {{0.13978, -0.995106, 0.756386}, 1.09894}, {{-0.313147, -0.432759,
> 0.207548}, 1.53836}}}
>
> I'd like to delete from the table elements of the type: {{x, x, ...., x}, y}
> when y is not in the interval [-1, 1].
> I was trying with DeleteCases, but with no success.
> Could you, please, help me.
> best regards
> Umberto
- References:
- DeleteCases
- From: "umberto" <umberto.prisco@unina.it>
- DeleteCases