Is there a way to map associative arrays

Freddy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 1 16:14:56 PDT 2014


#!/usr/bin/rdmd
import std.algorithm;
import std.stdio;
uint[uint] test;

void main(){
	test=[0:2 ,1:3 ,2:4];
	writeln(test.map!(a=>a-2));
}

$ ./test.d
./test.d(8): Error: template std.algorithm.map cannot deduce
function from argument types !((a) => a - 2)(uint[uint]),
candidates are:
/usr/include/dmd/phobos/std/algorithm.d(375):
std.algorithm.map(fun...) if (fun.length >= 1)
Failed: ["dmd", "-v", "-o-", "./test.d", "-I."]


More information about the Digitalmars-d-learn mailing list