POV-Ray : Newsgroups : povray.beta-test : Looping Dictionaries Server Time
26 Dec 2024 18:50:30 EST (-0500)
  Looping Dictionaries (Message 1 to 3 of 3)  
From: ingo
Subject: Looping Dictionaries
Date: 1 Dec 2018 14:45:14
Message: <XnsA9ABD31EF6948seed7@news.povray.org>
As the dictionary implementation seems to be based upon, or closely 
related to arrays, I tried to loop over a dict as if it where a Array. 
This doesnt work and yes, the docs are silent on this.

Is it possible?
Can it be made possible? (Are dicts kept in order?)

get the length / dimension_size and loop over a dict getting a key value 
pair as pseudo tuple as result.

#while (i < dimension_size(dict,1)-1)
    	#local (key, value) = dict[i];
#end

It would be useful when working with splines or boning and inverse 
kinematics to have both ways of accessing a dict. Another one would be 
appending dictionaries without knowing all the exact keys.

ingo


Post a reply to this message

From: clipka
Subject: Re: Looping Dictionaries
Date: 2 Dec 2018 00:01:04
Message: <5c036710@news.povray.org>
Am 01.12.2018 um 20:45 schrieb ingo:
> As the dictionary implementation seems to be based upon, or closely
> related to arrays, I tried to loop over a dict as if it where a Array.
> This doesnt work and yes, the docs are silent on this.
> 
> Is it possible?
> Can it be made possible? (Are dicts kept in order?)

/Some/ mechanism to make it possible is on the ToDo list, but the plans 
are still quite fuzzy.

You could work around the lack of such a feature by maintaining a 
separate array of keys.


Post a reply to this message

From: ingo
Subject: Re: Looping Dictionaries
Date: 2 Dec 2018 03:36:18
Message: <XnsA9AC61B54D273seed7@news.povray.org>
in news:5c036710@news.povray.org clipka wrote:

> Am 01.12.2018 um 20:45 schrieb ingo:
>>[...]
>> Is it possible?
>> Can it be made possible? (Are dicts kept in order?)
> [...]
> 
> You could work around the lack of such a feature by maintaining a 
> separate array of keys.
> 

That's what I've done so far, keeping several Arrays as 'indexes' in the 
dict.

Thanks,

ingo


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.