[Date Index] [Thread Index] [Author Index]
Rational[a,b] vs Rational[1,2]
I find it potentially hazardous that Head does not distinguish the cases of Head[1/2] and Head[Rational[a,b]] Thus these both get transformed... 1/2 /. Rational[r_,s_]-> foo[r,s] Rational[a,b] /. Rational[r_,s_] -> foo[r,s] but compare ... 1/2 /. 2->4 Rational[a,2] /. 2->4 I'm not saying I'm surprised by this, of course. Perhaps Rational[a,b] should be converted to a/b unless both a and b are numbers. Oh, for some fun, try Rational[1/2,4]. RJF PS, I used version 7.