5
$\begingroup$

For some particular reasons I have a nested list, e.g.,

Dimensions[ourlist]={N,M,3}

where the third dimension includes 3 elements: the function, its first and second derivatives. So basically, each entry of the third dimension looks like this:

{ 1 , {1,1,1} ,{{1,2,3},{1,2,3},{1,2,3}} }

I can't figure out how to delete cases in this nested list (NxMx3) in which the norm of the gradient, i.e. the vector {1,1,1}, is larger than a threshold value. Any suggestion would be appreciated. Thank you!

$\endgroup$
2
$\begingroup$

One way is to use Pick:

ourlist = Table[{"f", RandomReal[1, 3], "f''"}, {2}, {5}]



Pick[
 ourlist,
 Map[Norm[#] <= 1. &, ourlist[[All, All, 2]], {2}],
 True
]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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