Compact string representation of a float

dmbates
Mon, 08 Jan 2024 16:38:01 +0000
General Usage

I want the compact (in the sense of IOContext(io, :compact => true)) string representation of a floating point number or vector for inclusion in a Quarto document. Currently I define a function

function compact(x; buf::IOBuffer = IOBuffer())
  print(IOContext(buf, :compact => true), x)
  return String(take!(buf))
end

Am I missing a more obvious way of doing this?

3 posts - 2 participants