I want to change a numerical list of the (examplary) form {1,3/2,5}
to {1,{1,2},5}
.
First solution
{3, 5/2, 1 } /. Rational[a_ , b_] -> {Floor[a /b], Ceiling[a/b ]}
(*{3, {2, 3}, 1}*)
works fine. Second try
{3, 5/2, 1} /. (in_ /; (! IntegerQ[in]) :> {Floor[in], Ceiling[in]} )
(*{{3, 2, 1}, {3, 3, 1}}*)
fails.
What's wrong with my second version? Thanks!