Message Boards Message Boards

0
|
3686 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Graphics question on code in "Adventures of a Computational Explorer" book?

I have a question about the code on page 10 of Wolfram's new book "Adventures of a Computational Explorer". When I enter the code

Row[Graphics[{RandomColor[], Disk[]}, ImageSize > 5 #] & /@ %7]

I get all the disks to be the same size! ImageSize >5 has no effect? So, my question is: why are the disks in the output on page 10 all different sizes?

POSTED BY: Jay Wolkowisky
6 Replies

Disregard my previous statement! You are correct! I left out the "-" in the "->"!

POSTED BY: Jay Wolkowisky

When I input the statement in the book (allowing for the previous input number) the output has all the disks are the same size, not random sizes?

POSTED BY: Jay Wolkowisky

It doesn’t need RandomReal. The %7 in that statement refers to the output of the previous statement, which is a list of the decimal digits of pi. So the size of each disk is 5 times a decimal digit of pi. That’s where the randomness comes in.

POSTED BY: John Shonder

I'm totally aware that one must use the Input number of the previous output, but as it is written in my copy of the book it does NOT have "RandomReal" in the input! Does your copy of the book have this in the input statement?

POSTED BY: Jay Wolkowisky
Posted 4 years ago

Hi Jay,

I do not have the book, so I have no idea what %7 is. As I said in my reply "Or, use another list of numbers to specify the size e.g." I chose to use RandomReal.

POSTED BY: Rohit Namjoshi
Posted 4 years ago

The %7 refers to the 7'th output value, Out[7]. It is usually a bad idea to reference output by number since the numbers can change depending on the order in which cells are evaluated. That is probably why it is not working as expected.You can fix it by evaluating the cells in the order they are evaluated in the book. Or, use another list of numbers to specify the size e.g.

Row[Graphics[{RandomColor[], Disk[]}, ImageSize -> 5 #] & /@ RandomReal[{1, 15}, 10]]

enter image description here

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract