4
$\begingroup$

Consider for example list = {1 < x < 1.8, x > 1.8, x == 1. || x == 1.8}.

I want to get the (floating) numbers in this list, i.e. 1. and 1.8. They can be accessed with Take, for example list[[1, 3]] returns 1.8. So I could iterate over each element of the list, find it's dimensions and select each part and keep only floating numbers. But I suppose there is a simpler way.

The question is, is there a simple function to return {1.,1.8} from list?

$\endgroup$
1
  • 3
    $\begingroup$ Cases[list, _Real, Infinity] // DeleteDuplicates $\endgroup$ Sep 5, 2016 at 20:16

1 Answer 1

4
$\begingroup$

Cases would work here.

Cases[list, _Real, Infinity] // DeleteDuplicates

{1.8, 1.}

$\endgroup$

Your Answer

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

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