Bill Allombert on Tue, 23 Apr 2019 22:45:16 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Iterating over a map content


On Tue, Apr 23, 2019 at 10:17:56PM +0200, Jérôme Raulin wrote:
> Hi,
> 
> Is there a better way of iterating over an entire map content than something
> like :
> 
> 	map = Map();
> 	\\ Do stuff with map
> 	mapkeys = Vec(map);
> 	for (i = 1, # mapkeys,
> 		key = mapkeys[i];
> 		value = mapget(map, key);
> 		\\ Do other stuff with (key, value)
> 	);

Instead of Vec(map), you can use Mat(map) which give you the list of 
key/value pairs directly.

Cheers,
Bill.