1

I have a random list of points and I would like to execute statement on it, If xPoint^2/2 - yPoint > 0, color that point red.

I have difficulty on executing that algorithm

L=Sequence((RandomBetween(-6,p),RandomBetween(-6,q)),i,1,100)
Sequence[If[ x(Element(L, i))^2/2^2 - y(Element(L, i)) >=0,SetColor(Element(L, counter),"Red")],i,1,50]
chris burgees
  • 63
  • 1
  • 2
  • 8

1 Answers1

1

Most GeoGebra commands are declarative, they define relationships between objects. Exception to that rule is scripting commands like SetColor that are imperative. It is not possible to call scripting SetColor from a declarative command like Sequence. However you can define the list of objects that you want to make red:

l2=KeepIf[ x(A)^2/2^2 - y(A) >=0, A, L]

and then you can make these objects red either from the UI or using SetColor(l2,"red").

This way you end up with two lists where l2 covers some elements of l1. If it's a problem, you can define l3=L\l2 and hide the original list L.

In the original question the second list only has 50 elements while L has 100, if it's intentional you can use First(L,50) as the last argument of KeeepIf.

Zbynek
  • 412
  • 4
  • 17