Functional Programming in Geogebra

From the 5.0 Manual of Geogebra:

It’s actually enough to provide a single list to Zip[]. This makes it a shorter alternative to Sequence[] when all you want is to traverse a list. For example, Zip[a^2, a, listOfNumbers] is much shorter than Sequence[Element[listOfNumbers, a]^2, a, 1, Length[listOfNumbers]] (albeit in this case it’s easier to just do listOfNumbers^2.)

This already is a big progress – traversing lists is a task needed very often when thinking in a functional way. As of late access to elements is possible using short notation

listOfNumbers(1), ..., listOfNumbers(-1)

as usual in many other languages. So the above example boils down to

Sequence[listOfNumbers(a)^2, a, 1, Length[listOfNumbers]]

which is better, but clearly Zip[a^2, a, listOfNumbers] is much better. Unfortunately the long form is need at this time of writing for some tasks as Zip does not digest all expressions – substitution lists as given by Solve for example are not possible like in a statement


you have to use sequence.
But there are workarounds – avoiding Solve and using Solutions gives lists of values instead of substitutions – and Zip is ready to go!

As an example I want to show how to do function sketching: all possible locations are gathered with Solutions and are subsequently processed to get more information (how about the third derivative on these locations?) or produce output (like points to be shown in the graph).

Leave a Reply