www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Build AA from two simple array

reply Andrey <saasecondbox yandex.ru> writes:
Hello,
I have got 2 simple arrays with the same length:
 int[] values = [1, 2, 3, 4, 5];
 char[] keys = ['a', 'b', 'c', 'd', 'e'];
  auto result = buildAA(keys, values); // [a: 1, b: 2, c: 3, d: 
 4, e: 5]
I want to build AA "result" using "values" and "keys". How to do it?
Mar 23
parent Alex <sascha.orlov gmail.com> writes:
On Saturday, 23 March 2019 at 09:25:52 UTC, Andrey wrote:
 Hello,
 I have got 2 simple arrays with the same length:
 int[] values = [1, 2, 3, 4, 5];
 char[] keys = ['a', 'b', 'c', 'd', 'e'];
  auto result = buildAA(keys, values); // [a: 1, b: 2, c: 3, d: 
 4, e: 5]
I want to build AA "result" using "values" and "keys". How to do it?
for example via assocArray https://dlang.org/library/std/array/assoc_array.html
Mar 23