Module:Rational: Difference between revisions

Plumtree (talk | contribs)
mNo edit summary
Plumtree (talk | contribs)
mNo edit summary
Line 1,320: Line 1,320:
-- return a rational number in ket notation
-- return a rational number in ket notation
-- NaN, infinity, zero values use special representations
-- NaN, infinity, zero values use special representations
function p.as_ket(a, frame, skip_many_zeros, only_numbers)
function p.as_ket(a, frame, skip_many_zeros, only_numbers, sep)
skip_many_zeros = skip_many_zeros or true
skip_many_zeros = skip_many_zeros or true
only_numbers = only_numbers or false
only_numbers = only_numbers or false
sep = sep or ' '
if type(a) == 'number' then
if type(a) == 'number' then
a = p.new(a)
a = p.new(a)
Line 1,356: Line 1,357:
if u.is_prime(i) then
if u.is_prime(i) then
if i > 2 then
if i > 2 then
template_arg = template_arg .. ' '
template_arg = template_arg .. sep
end
end
template_arg = template_arg .. (a[i] or 0)
template_arg = template_arg .. (a[i] or 0)
Line 1,364: Line 1,365:
template_arg = template_arg_without_trailing_zeros
template_arg = template_arg_without_trailing_zeros
if #template_arg > 0 then
if #template_arg > 0 then
template_arg = template_arg .. ' '
template_arg = template_arg .. sep
end
end
template_arg = template_arg .. '0<sup>' .. zeros_n .. '</sup> ' .. (a[i] or 0)
template_arg = template_arg .. '0<sup>' .. zeros_n .. '</sup> ' .. (a[i] or 0)