Balanced ternary: Difference between revisions

Content added Content deleted
(/* {{header|jq)
Line 3,406: Line 3,406:
end
end
end
end
| sub("^00*";"")
| sub("^00*";"")
| if . == "" then "0" end
end ;
end ;


Line 3,427: Line 3,428:
def new:
def new:
if type == "string" and all(chars; IN("0", "+", "-"))
if type == "string" and all(chars; IN("0", "+", "-"))
then sub("^00*"; "")
then sub("^00*"; "") | if . == "" then "0" end
elif type == "number" and trunc == .
elif type == "number" and trunc == .
then toBT
then toBT