# Misbehaving Table

(To be fair, it's not Mathematica that is 'misbehaving'; this is actually down to my limited coding skills.)

I have the following Table:

Module[{l = 5},
table1 = Table[RandomInteger[{-100, 100}]/
RandomInteger[{-100, 100}], {n, 1, l}];
table2 = ContinuedFraction[table1];
TableForm[Transpose[{table1, table2}],
TableHeadings -> {None, {"R", "CF of R"}}]]


The ContinuedFraction function produces the correct data, but not in Table-friendly form. The "CF of R" column lists the continued fractions vertically. I want some form of horizontal representation to make the Table more readable. In a totally ideal world, I'd like the continued fractions to appear as (for example)

[1;2,7,2,3,5]


i.e., reformatted so that (a) the continued fraction appears as a row in the Table, not a column-per-item, and (b) it uses standard traditional formatting.

How do I do this?

## 1 Answer

If I understand you:

cfform[{b_, d___}] := Row[{"[", b, ";", ##, "]"}] & @@ Riffle[{d}, ","]

TableForm[{table1, cfform /@ table2}\[Transpose],
TableHeadings -> {None, {"R", "CF of R"}}] • Hi @Mr Wizard. Many thanks. – Richard Burke-Ward Dec 11 '19 at 12:42