New answers tagged

4

You can use With[{k = k}, ...] to inject the iterator values in the first argument in Table: Table[With[{k = k}, Button["d" <> ToString[k], Echo@d[k]]], {k, {4, 6, 8, 10, 12, 20}}] Alternatively, define a function outside Table and use it as the first argument in Table: btn[x_] := Button["d" <> ToString[x], Echo@d[x]] Table[btn[k], {k, {4, 6, ...


4

Try this: buttons = Button["d" <> ToString[#], Echo@d[#]] & /@ {4, 6, 8, 10, 12, 20}; Column[buttons] or ButtonBar["d" <> ToString[#] :> Echo@d[#] & /@ {4, 6, 8, 10, 12, 20}] Of course, from this example it's easy to customise the style. For example, I would change d[n)] as follows: d[n_] := "d" <> ToString[n] <> ": "...


Top 50 recent answers are included