Create list using {Key:Value} pairs?

Math123 shared this question 3 months ago
Answered

How to create a list using Key : Value pairs, because it want to append element in list but need to remember elements by keys name/ property name.

Also how to call element value using key name?

Comments (10)

photo
2

l1={{"apple", "1"}, {"banana", "3"}, {"orange", "7"}}

Element(Element(KeepIf( Element(a,1)=="orange",a, l1),1),2)

photo
1

Thanks Tang for reply,

Pls suggest solution if value are sliders a, b, c, d, e, f

l1 = {{"apple" , "(a , b , c)"} , {"banana", "(d , e , f)"}}

i want to cal key/property name "apple" in script (button onClick script) and want to set values (1 , 2 , 3) it automatically change a,b,c slider value.

When i needed any one of slider animate e.g: (1 , startanimation(b) , 2)

photo
1

Another way of saying : sliders a , b , c , d , e , f

apple = (a , b , c) or {a , b , c}

banana = (d , e , f) or {d , e , f}

l1 = {apple , banana}

I want to call apple from list in script and set values (1 , 2 , 3) it automatically set value of sliders.

Also if needed can be start animation any one of slider in script.

photo
photo
1

use element(l2,position) where position is an IndexOf( <Object>, l1 )

read the sort(list,key) command help

photo
1

I think this is what you described above (in the sense)

It was fun to coding this.

But I'm not sure if this is going to be useful for you.

Please: before you make new demands, check the solution and the possibilities very well and justify the benefit of the additional demand.

photo
1

Rami your solutions are always very helpful, but you become annoyed :smile:

"Please: before you make new demands, check the solution and the possibilities very well and justify the benefit of the additional demand."

Ans : All the problem arise because i want to control alpha (unfortunately this is not working in GGB) and rbg (also no command for hsl and hsv) of every object most of the time it is needed to change rainbow color.

My idea is that make 3 sliders for every single object and put in hue, saturation, value position in dynamic color properties.

Slider a , b , c Free Point : A = (2 , 3)

a at hue in A

b at sat in A

c at val in A

make same variable for every single object to control color of hsv e.g:

localList : A_{hsv} = (a , b , c) or {a , b , c} any of the idea work

make global list for every single object

globalList = {{A_{hsv}} , B_{hsv} etc..}

append all new object hsv value in global list so number of objects become less as compared local list of object. it make software heavy.

Now then whenever i needed call A_{hsv} by property name/key from global list and change values of slider a , b, c in script and whenever needed animate any one of slider can have rainbow effect and other slider value static.

Hope my english sense to you....! :smile:

photo
1

It is also much more better if line break single line code in multiple line. Otherwise long coding of single line is hard to read and understand and solve problem in scripting.

photo
1

Yes, I am annoyed with myself because once again I have not asked what the purpose of the requirement should be or what should be achieved with it.

It does not seem to be one of your strengths to simply describe what you want to do. And in such a way that the description does not contain any GGB specifications.

Even your last description does not meet this requirement.

Try it again.

photo
1

rami calm down drink water you are nice person.. always supported.

I told you the description what i try to get. if you have better solution for alpha , hsl and hsv of every single object individually. Pls share your solution.

I do this because students in class can not understand whenever i popup objects with check boxes until i described. So i am animating objects, creation of objects make attention and self-explanatory saved a lot of time and make better understanding.

I need alpha control and hsv and hsl values.

photo
2

No.

I do not want to know what they need, but what they want to achieve.

To a certain extent this is included in the last post.

Here's what they probably want:

"I want paths (lines, polygons, conics etc.) to appear or disappear smoothly in a certain time window (about 1-3 seconds) and at a certain point in time. The point in time is determined by the activation of a user element (button, checkbox, move, click).

Alternatively, the color of the path should move through the color circle in this time window."

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

In this manner it would be useful for me.

But: is the draft complete and correct?

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

Note: For me, it continues tomorrow.

photo
© 2020 International GeoGebra Institute