weird (strange) behavior of sequence-polyline combination
Answered
I have a list of points (about 1000 points) named pf.
I needed the distance of each point from the first point. Somebody in the forum (I believe it was "rami") gave me the hint:
Sequence(0 + Polyline(First(pf,n)),n,1,Length(pf)) - it worked AND was fast!
By further analyzing I removed "0 +" in the command above - and now GG freeezes. (This does not happen if I decrease the size of the list to 100 but you can "feel" the delay )
My guess: Because of "0+" only the length of each "Polyline"-command find its way to memory - there were no objects "Polyline" constructed.
Can anybody explain this strange behavior? (is my guess correct?)
Please post your .ggb file
0+polyline() creates a sequence of numbers. It requires less memory that sequence of polylines that internally is a collection of points and segments
same as mathmagic but with others words
Sequence(0 + Polyline(First(pf,n)),n,1,Length(pf)) create a list of length of polyline and each element is the length of a polyline (1 value)
Sequence(Polyline(First(pf,n)),n,1,Length(pf)) create a list of polylines and each element has a lot of points
--------------------------------------------------------------------------------------------------
Quote:Can anybody explain this strange behavior?
no: it is also for me strange (I try first with Length() but this not works and I found "0+" as "workaround")
but often (not always) ggb give back a value of an object instead the object himself. The exact rule I do not know (for example Area for Polygon)
Quote: (is my guess correct?) Yes.
-----------------------
you can find your own threads when you click on your own name in your first post in on of your own threads.
https://help.geogebra.org/profile/128650#/topics
there you can find https://help.geogebra.org/t...
OK - thank you folks for your answers - especial "rami" (I hope I am not going on your nerves) but I wondered at your answer about "0+" at this command - seems to be useless here, but now I understand.
Thanks to all!
Only for them who visit this thread:
an alternative (but needs 2 command lines)
distances= Sequence(Distance(pf(n), pf(n - 1)), n, 2, Length(pf)) //distance of 2 neighbors
Join({0}, Sequence(Sum(distances, n), n, 1, Length(distances))) // sum up until n
advantage: no tricks with 0+
drawback: longer
Comments have been locked on this page!