Copy by value

gd shared this idea 14 years ago
Completed

I propose a prefix (e. g. %) which causes the variable or other expression after it to be evaluated when the command is issued, so that the definition in which it occurs will contain the current value of the expression and it will not be dependent on the variable (or variables in the expression). E. g.

    b=%a

would create a copy of a and make b a free object with the same value,

    r=%(random())

would give a random value to r which will not change in the future and

    b=%(b+a)

would increment the value of b (a free object) by a.


This would be useful for simple users to copy a variable and it would be necessary for the scripting system I propose.

Comments (8)

photo
1

Being able to save/copy by value would give powerful new options ... especially using and exploring 'semi-random' constructions and/or IterationList tools, sequences and loops ...

photo
1

Question: what is the difference to CopyFreeObject()

photo
1

b=%a

    SetValue(b,a)

    r=%(random())

SetVaue(r,random())

    b=%(b+a)
    SetValue(b,b+a)

photo
1

If a and b are segments, and I use:

b = CopyFreeObject(a)

How I get b as a full free object? (now I get a dependent object in the algebraic view, Sort by Dependency)

photo
1

(I would like to solve a circular definition)

photo
1

A segment() cannot be independent. It is allway dependent on 2 points.

Look at the new definition of b after executing b=CopyFreeObject(a).

It implicitly contains 2 free points: b = Segment((1.68, -0.6), (3.9, -1.48))

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

circular definition are not possible in GGB

What is possible: recursive definitions in Spreadsheet or with IterationList()

photo
photo
1

¿what circular definition? possible with script but we need the elements used in it

you can share the file and say the new element with circular definition

photo
1

Instead of the segments, I needed the distance between two points, so I made a single change in the definitions. With the distance value, I could solve the circular definition.Thanks for your help.

© 2023 International GeoGebra Institute