Zeckendorf arithmetic: Difference between revisions
m
→{{header|Julia}}
Line 1,278:
=={{header|Julia}}==
Influenced by the format of the Tcl and Perl 6 versions, but added other functionality.
<lang julia>import Base.*, Base.+, Base.-, Base./, Base.
▲import Base.*, Base.+, Base.-, Base./, Base.string, Base.!=, Base.==, Base.<=, Base.<, Base.>, Base.>=, Base.divrem
const z0 = "0"
Line 1,292 ⟶ 1,291:
tolen(x::Z, n::Int) = (s = x.s; while length(s) < n s = z0 * s end; s)
<(x::Z, y::Z) = (l = pairlen(x, y);
>(x::Z, y::Z) = (l = pairlen(x, y);
==(x::Z, y::Z) = (l = pairlen(x, y); tolen(x, l) == tolen(y, l))
<=(x::Z, y::Z) = (l = pairlen(x, y);
>=(x::Z, y::Z) = (l = pairlen(x, y);
!=(x::Z, y::Z) = (l = pairlen(x, y); tolen(x, l) != tolen(y, l))
Line 1,415 ⟶ 1,414:
end
function zeckendorftest()
|