Possible to copy a set of string points to a list of points?

Mads Frederik Toft shared this question 10 months ago
Answered

I have the following problem.

Have this list of points here in string form

list={"(1,2)","(3,4)","(5,6)"}

What I can do I can get ggp to execute every list element seperately so it becomes a point on its own.

e.g. A=(1,2), by typing execute({elemen(list,i)})

where i is the length of list.

However what I would love to is move the execute element/point to a seperate list its point form.

Meaning so I get a new, newlist={(1.2).(3,4),(5,6)}

How would I go about doing this? And is possible?

Comments (15)

photo
1

Perhaps, some thing like

Sequence(if(k==0,Execute({"zz=1"}),Execute({list(zz),"zz=zz+1"})),k,0,3)

photo
1

An alternative (as list)

photo
1

Thank you for your answer, But GG says the input is invalid?

photo
1

What did you do where, how did you enter?

I test str2pnt without problems with GGB 5.0 and GGB 6.0

in GGB 5.0 bring "list" in the input-bar (F3), change the list (do not forget quotation marks)

Enter, check "newlist"

photo
1

I opened the file, copied the script. I might not just be sure enough in GG yet, but am I suppose to add it the script under the list?

photo
1

you must not copy the script.

only this:

bring the object "list" in the input-bar (in GGB 5 with F3) , change the list (do not forget quotation marks)

Enter, check "newlist" (this object is automatic updated when you change "list")

photo
1

Thank I get it now :)


But I would like to do is to include it in the following:


SetValue(text2,text)


SetValue(list,a+1,text2)


Execute({Element(list, a)})


Your code (Execute(Zip(“SetValue(newlist,Length(newlist+1 ,”+S+“)”, S,list))


SetValue(text,"")


where text2=""


What I would like to include it in, that a student using an input box types a point (x,y) as a string it adds the point to list (as a string). Then convert it from string to newlist, and then have ggp show it as a point.


Hope it makes sense? :)

photo
photo
1

I tried this myself

Execute("{SetValue(Element(list, a),Element(newlist, a)}")


Meaning I would to copy the point a position a in the list named list on the same position in newlist. But this ting GG reads its as a point (x,y) instead of a string "(x,y)".

photo
1

quote

What I would like to include it in, that a student using an input box types a point (x,y) as a string it adds the point to list (as a string). Then convert it from string to newlist, and then have ggp show it as a point.

================================================================

Your description is feasible (see attachment).

But it is probably not complete regarding:

- delete an item

- insert a point before/after an existing point

- Change an existing point

All this is also possible but ambitious and expensive.

And I think the most important point: it's no fun at all to define the points.

.

Alternatives:

a) The student use the spreadsheet to define the points, maybe some points are predefined.

b) About 10 - 100 points are predefined in a "Box" in the Grafic1. The Student move some of this points from the "Box" to the desired place. The order could be defined by the name_{index}.

A combination of a) and b) is also possible.

---------------------------------------------------------------

If you want to continue with your concept, I recommend to use 2 boxes for the point definition instead of one input box.

And by the way: converting a list of points into a list with string is much easier than vice versa (see attachment)

photo
1

And one more variant c)

With a button the student creates as many points as he needs. Since there are points in the spreadsheet, it is always known which points (name and value) were created with the button. The created points can be moved (update value) or deleted.

See appendix

photo
photo
1

seguramente llegue un poco tarde pero en respuesta a la peticion inicial

Execute(zip("MM"k"="list(k),k,Sequence(Length(list))))

photo
1

and the same as list-output (as requested)


  • list={"(1,2)","(3,4)","(5,6)"}
  • Execute(Join(zip("Z"k"="list(k),k,Sequence(Length(list))), {"newList=CopyFreeObject(Z1:Z1000)","Delete(Z1:Z1000)"}))

But for me the variante with "SetValue(<list>,<ndx>,<value>)" the most time is better (and more quick). Example here. See there object "list" onUpdate.

photo
photo
1

for a list of points I propose execute({ " listP={" + (Take(Sum(Zip("," p, p, list)), 2) + "}")})

it is possible setvalue instead = also

photo
1

Great: When object names are available as a text list and a dependent list is to be created.

photo
photo
1

Hi,

Thank you, interesting conversions!

I experimented a bit with

list= {"(2, 5)", "(1,10)"}

Execute({ “ listP0={” + (Take(Sum(Zip(“,” p, p, list)), 2) + “}”)})

→ listP0 = {(2, 5), (1, 10)}

Execute({ “ listP1={” + ( Zip(p, p, list) + “}”)})

→ listP1 = {{"(2, 5)", "(1,10)"}}

Execute({ “ listP2={” + ( Sum(Zip(p, p, list )) +“}”)})

→ listP2 = {(2, 5) (1, 10)}

→{52}- Sum removes quotes and commas → scalar multiply!!!!!!!!!!!

© 2019 International GeoGebra Institute