2
$\begingroup$

Apply Style to the letters A, B , C and D according to the specifications listed below. The number represents the font size and the color represents the font color. (Hint: Use Apply.)

Input:

{{"A",25,Red},{"B",30,Green},{"C",35,Blue},{"D",40,Brown}}

Expected Output:

enter image description here

After going through the Apply section (https://reference.wolfram.com/language/ref/Apply.html), I fail to figure out how Apply can be applied for this problem.

More explanation that would help solve the problem appreciated.

$\endgroup$
0

1 Answer 1

3
$\begingroup$

I do not understand what you want. You say you want to change the style of the letters, then you show the expected output as something else. But if you mean you want to change the type of the letters, you can use Style

lis={{"A",25,Red},{"B",30,Green},{"C",35,Blue},{"D",40,Brown}}
Style[#[[1]],#[[2]],#[[3]]]&/@lis

Mathematica graphics

You can also use short cut

Style @@@ lis

Mathematica graphics

If this is not what you want, may be you can clarify.

$\endgroup$
6
  • $\begingroup$ The solution has worked. Might be there is also a way by Apply. $\endgroup$ Commented Sep 12, 2021 at 7:47
  • 1
    $\begingroup$ @SplendidDigitalSolutions when you do Style["A",25,Red] Mathematica is smart and knows that 25 is for font size and Red is for color and it applies them to the first argument which is "A" . If you want to make {"A",25} be red, you can do Style[{"A", 25}, Red] $\endgroup$
    – Nasser
    Commented Sep 12, 2021 at 7:48
  • 1
    $\begingroup$ @SplendidDigitalSolutions you ask: Might be there is also a way by Apply. I am not sure what you mean. f @@@ expr is the same as Apply[f,expr,{1}] so the above answer is using Apply. $\endgroup$
    – Nasser
    Commented Sep 12, 2021 at 8:08
  • $\begingroup$ I was not aware f @@@ expr is the same as Apply[f,expr,{1}]. $\endgroup$ Commented Sep 12, 2021 at 8:13
  • 4
    $\begingroup$ @SplendidDigitalSolutions You have asked several questions that are quizzes or exercises from Wolfram-U courses. This is not the forum for asking those questions. They should be asked on the Wolfram Community site post corresponding to the course. The point of a quiz or exercise is for you to solve it, not ask someone else to solve it for you. $\endgroup$ Commented Sep 12, 2021 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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