Build Hash from Array in one statement ?
Gordon
me at home.com
Sat Feb 22 11:26:42 PST 2014
Hello,
Is there a way to quickly build a hash from the values of an
array?
A one-statement equivalent of:
T[] array_values ;
int[T] hash_values;
hash_values = map!(XXXX) (array_values) ;
Instead of:
for (v; array_values) {
hash_values[v] = 1;
}
in Perl, that would be:
%hash = map { $_ => 1 } @array;
---
Or, put differently, is there a way to convert values in an array
to keys of hash in one statement ?
Thanks!
-gordon
More information about the Digitalmars-d-learn
mailing list