Using Text Expressions in Geogebra Commands

Dave Yrueta shared this question 2 years ago

Hi --

I'm trying to define a complicated nested sequence, and wanted to see if I could simplify things by substituting saved text expressions for certain parameter values in the Sequence command.

Here's a very basic example:

a = 1(slider value)

b= 3 (slider value)

n=10 (slider value)

text1 = "(b-a)/n"

Sequence(text1 * t, t, 1, 4) would generate {.2, .4, .6, 8}.

I've tried using Execute command, but couldn't make it work. Any help would be greatly appreciated!

Comments (8)


I'm not sure about what you need. Do you need a sequence of nicely formatted fraction texts as final output, or a sequence of numeric values?

Please post your file.

Is it based on this? (see attached one)


you can not multiplicate text*number. do this:




Also you can define



Hi All --

Thanks very much for the responses. Unfortunately, I didn't make my intentions clear in the example. What I'm trying to do is better described as creating text that serves as a locally defined function within nested sequence commands. The function parameters are derived from index variable values linked to the sequence. The problem I'm trying to avoid is having to write expressions like this:

y(c_{1}(a + i dx)) + j(y(c_{2}(a + i dx)) - y(c_{1}(a + i dx))/n)

where "c_{1}", "c_{2}" are curves, "a" is a slider value, but "i" and "n" are sequence parameters. My goal was to simplify expressions like the one above by letting exp1 = "a + i dx", substituting expr1 into the sequence command where "a + i dx" occurs, and have GeoGebra evaluate the text as a command.

It's occurred to me that I might be able to solve this problem by breaking up by sequences into separate lists using ListIteration, and then combining them into a single nested sequence. So this particular problem might be moot, but I'm still interested in knowing if something resembling "locally defined functions" can be created within a sequence command.



do you mean like

f(t)=(b-a)/n t



Please post your .ggb file


Mathmagic -- Yes, that works. But I'm also interested in more general functions -- for example, a function that will retrieve the x coordinate of the i^th element of a list of points:

Example: f(i) = x(Element(ListOfPoints,i))

I tried that, and it doesn't seem to work.

Michael -- Many thanks for your attention to my question. I've figured out a more efficient way to accomplish what I've set out to do, so I no longer have a need to produce "locally defined functions." At any rate, if you're interested, I've included a link below to the file I was working on -- it might give you a better idea of what I was trying to do.

Thanks again for a great product! I can't imagine teaching without it.



f(i) = x(Element(ListOfPoints,i)) is not OK syntax in GG

for this XL=x(LOP) creates the list and XL(i) is the i^th element of list of x coords

© 2023 International GeoGebra Institute