2
$\begingroup$

I was under the impression MMA directly substituted everything when assigned. Obviously I'm missing something subtle with either how substitution works in a notebook or how the Disk function takes an expression. (I guess the 3rd option might be that it's some sort of graphical bug in the WebGL performance of MMA online.) Do I need to change the Head of the "d" expression? How do I do that? This is a simplified version of a Neat Example for Disk in Wolfram doc center. In any case, I'd really like to learn about what's going on here.

Graphics[Table[Disk[RandomReal[4,{2}],RandomReal[1]],40]]

enter image description here

Clear[d];
d:={RandomReal[4,{2}],RandomReal[1]}
Graphics[Table[Disk[d],40]]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ It is a {} issue. You have many of them. Try this Graphics[Table[Disk[Sequence@@d],40]] and see if it works for you. $\endgroup$ – Nasser Oct 17 '17 at 3:26
  • $\begingroup$ Yes that fixed it. Did you want to answer this? Sequence:"represents a sequence of arguments to be spliced automatically into any function." $\endgroup$ – BBirdsell Oct 17 '17 at 3:30
1
$\begingroup$

Passing the result of d as sequence resolves the extra {} issue.

From help

Mathematica graphics

So this should now work

Clear[d];
d:={RandomReal[4,{2}],RandomReal[1]}
Graphics[Table[Disk[Sequence@@d],40]]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Boom. The internet works! Problem solved. Thank you! $\endgroup$ – BBirdsell Oct 17 '17 at 3:34
1
$\begingroup$

Alternatives.

SeedRandom[42]
d := {RandomReal[4, {2}], RandomReal[1]}
Graphics[Table[Disk @@ d, 40]]

SeedRandom[42]
d := Sequence[RandomReal[4, {2}], RandomReal[1]]
Graphics[Table[Disk @ d, 40]]

Both produce

blobs

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.