Convert a list of points to separated points

Clueid shared this question 4 months ago
Answered

Hello,


Given a list of points, is there a command or script to automatically separate all points in this list to separated points so that I can interact with and connect with segments and etc...?


Bonus question: how can I determine the cardinality of a list?


I thought about:

i = 1

Repeat(cardinality(l1), Execute({"Element(l1, i)", "i = i +1"})


But it didn't work :( ... I also changed i into a parameter like this:


Repeat(cardinality(l1), Execute({"Element(l1, %1)", "%1 = %1 +1"}, i)

Comments (4)

photo
2

cardinality = Length


try

Execute(Sequence("A_{"+k+"}=Element(l1,"+ k+")", k,1,Length(l1) ))

photo
1

Great! thanks..

Can the new points also inherit the definition of the points in the list?

Here's my trial:


Execute(Sequence("A_{"+k+"}="+FormulaText(Element(l1, k), false), k,1,Length(l1)))

But the problem is that Execute() does not accept FormulaText(X, false).. Any ideas?


Thanks in advance.

photo
photo
2

Whenever possible: use the version of Noel (more robust, faster)

In rare cases (e.g. filter over random numbers) you can use Repeat() or JS.

If you use Repeat():

  • no conditions
  • the index must be maintained by yourself.
  • if you have a end-condition: handling inside Execute() (inside Repeat() it's not possible/tricky)

The most robust syntax is as in the example with Execute(). Inside Execute() no restrictions exists.

The Execute list as an independent object in the Algebra View has the higher performance and can be more transparent(?)

photo
1

Thank you for the reply, it really helps =)

photo
© 2020 International GeoGebra Institute