Group Abstract Group Abstract

Message Boards Message Boards

1
|
3.1K 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 3 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
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
POSTED BY: Phil Earnhardt
Posted 2 years ago

Thanks for your answers, Rohit. You consistently provide great responses here.

I was thrown off by this question, because Blend doesn't take a list as an argument. I finally figured out to run FullForm on the statement to see what was really happening. Aha! Table is just semantic sugar -- a "macro" in other programming languages. Blend doesn't really exist, either. It's now as clear as black and white -- or maybe RGBColor -- what's going on with this exercise. I increased the interval size to decrease the clutter:

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

List [RGBColor [1., 0.5, 0.],
      RGBColor [0.8999999999999999, 1. , 0.],
      RGBColor [0.5, 1., 0.20000000000000018],
      RGBColor [0.5, 0.6999999999999997, 0.5],
      RGBColor [0.9000000000000004, 0.5, 0.5],
      RGBColor [1., 0.5, 0. ]]

The two takeaways I got from this:

Any sort of assumptions you have mapping other languages onto the Wolfram Language are probably wrong. The WL is a different beast.

I do not understand all the ways that mappings work in this language. Once I do, I may be on my way to being a WL Wizard. Going through many exercises is quite valuable. Stephen's "Elementary Introduction [...]" is my new favorite tutorial.

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