Group Abstract Group Abstract

Message Boards Message Boards

1
|
3K Views
|
4 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Difficulty with Blend: how to Blend a Color with a Table of Colors?

Hello,

I'm brand new to Wolfram, and I'm struggling on one of the practice problems in the tutorial. Problem 7.7 asks : "Make a list of colors obtained by blending yellow with hues from 0 to 1 in steps of 0.05."

This seems very simple, but everything I try seems to fail:

If someone could tell me what I am doing wrong, it would be greatly appreciated!

POSTED BY: Orion Strayer
4 Replies
Posted 2 years ago
POSTED BY: Phil Earnhardt
Posted 2 years ago

Hi Phil,

You are welcome.

Table is just semantic sugar -- a "macro" in other programming languages. Blend doesn't really exist, either.

Actually, it is not semantic sugar and they both do exist as functions (pattern -> replacement). The reason they do not appear in the FullForm is that its argument has been evaluated before passing it to FullForm. It does not hold its arguments

Attributes@FullForm
(* {Protected} *)

So it is the FullForm of the evaluated expression.

1 + 1 // FullForm
(* 2 *)

1 + 1 // Hold // FullForm
(* Hold[Plus[1, 1]] *)

At its core, the WL is a term rewriting system. Watch the 3 video presentations by Professor Richard J. Gaylord for an overview of how WL uses term rewriting. This is also worth a read.

POSTED BY: Rohit Namjoshi
Posted 2 years ago

Going back to this homework exercise:

Table[Blend[{Yellow, Hue[x]}], {x, 0, 1, .20}] // Hold // FullForm

Returns:

Hold [Table [Blend [List[Yellow, Hue [x]]], List[x, 0, 1, 0.2` ]]]

Blend will take a list of 2 colors and a value x, which determines the weighting of the 2 colors to blend. I presume that providing that list with no 2nd argument gives a default blending-value of .5 -- and it's just a bug in the documentation that this one-argument option is not listed. I'll report that bug in the docs.

The real value of your comment is learning when to apply Hold to see what's going on under the hood. I see the obvious error in my interpretation of what was happening. Much more to learn! I will put those videos on my list to study, but it will take some time (and probably lots of popcorn) to get through them. Thank you again.

POSTED BY: Phil Earnhardt
Posted 2 years ago

Hi Orion,

You were close with Attempt 3, just misplaced parenthesis

Table[Blend[{Yellow, Hue[x]}], {x, 0, 1, 0.05}]
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