Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.6K Views
|
2 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Why does my pure function fail in this case?

I create a matrix.

basis = {{1, 0}, {0, 1}}

Which I want to become a graphic. This code works fine

Graphics[{Blue, Rectangle[basis[[1]], basis[[2]]]}, Axes -> True, 
 PlotRange -> {{0, 10}, {0, 10}}]

But this does not, although it seems to me to be the same

Graphics[{Blue, Rectangle[#1, #2] & /@ basis}, Axes -> True, 
 PlotRange -> {{0, 10}, {0, 10}}]
POSTED BY: Roger J Brown
2 Replies
Posted 2 years ago

I'm sure others can explain this better, but as I understand it, the function Rectangle requires two inputs: two pairs of x-y coordinates. However, when you map over basis, you're inputing one pair of coordinates at a time to the function. Try this:

Graphics[{Blue, Rectangle[#[[1]], #[[2]]] &[basis]}, Axes -> True, 
 PlotRange -> {{0, 10}, {0, 10}}]
POSTED BY: John Shonder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use