I have a small complaint about julia. I use all the time matrices of Rational
s, like
> 10×10 Array{Rational{Int64},2}:
> 2//1 0//1 0//1 0//1 0//1 0//1 0//1 0//1 0//1 0//1
> 0//1 2//1 0//1 0//1 0//1 0//1 0//1 0//1 0//1 0//1
> 0//1 0//1 4//3 -2//3 2//3 0//1 0//1 2//3 -2//3 -2//3
> 0//1 0//1 -2//3 4//3 2//3 0//1 0//1 2//3 -2//3 -2//3
> 0//1 0//1 2//3 2//3 1//3 1//1 1//1 1//3 2//3 2//3
> 0//1 0//1 0//1 0//1 1//1 1//1 -1//1 -1//1 0//1 0//1
> 0//1 0//1 0//1 0//1 1//1 -1//1 1//1 -1//1 0//1 0//1
> 0//1 0//1 2//3 2//3 1//3 -1//1 -1//1 1//3 2//3 2//3
> 0//1 0//1 -2//3 -2//3 2//3 0//1 0//1 2//3 4//3 -2//3
> 0//1 0//1 -2//3 -2//3 2//3 0//1 0//1 2//3 -2//3 4//3
I find it perfectly acceptable that to input a Rational
, you have
to write a//b
. But I find pretty horrible that they are output the same
way. I would like to see:
10×10 Array{Rational{Int64},2}:
2 0 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 0 4/3 -2/3 2/3 0 0 2/3 -2/3 -2/3
0 0 -2/3 4/3 2/3 0 0 2/3 -2/3 -2/3
0 0 2/3 2/3 1/3 1 1 1/3 2/3 2/3
0 0 0 0 1 1 -1 -1 0 0
0 0 0 0 1 -1 1 -1 0 0
0 0 2/3 2/3 1/3 -1 -1 1/3 2/3 2/3
0 0 -2/3 -2/3 2/3 0 0 2/3 4/3 -2/3
0 0 -2/3 -2/3 2/3 0 0 2/3 -2/3 4/3
As it is, I have the feeling that I must change my glasses whenever I print
a matrix of Rationals
. As I understood, you would just have to change (or to
write a new)
function Base.display(x::Rational)
to do the trick. Do people think this would be reasonable?