On Sunday, 27 December 2015 at 00:27:12 UTC, Ali Çehreli wrote:
On 12/26/2015 11:46 AM, karthikeyan wrote:

> Thanks but the following returns an error for me
>
>    import std.algorithm.comparison : equal;
>    import std.range : chain;
>    int[] arr1 = [ 1, 2, 3, 4 ];
>    int[] arr2 = [ 5, 6 ];
>    auto dd = map!(z => z * z, c => c * c * c)(chain(arr1,
arr2));
>    writeln(dd);
>
> Error :
>
> /usr/include/dmd/phobos/std/meta.d(546): Error: template
instance
> F!(__lambda2) cannot use local '__lambda2' as parameter to
non-global
> template AppliedReturnType(alias f)

That looks like a bug to me. Please report here:

  https://issues.dlang.org/

You can call tuple() as a workaround:

import std.stdio;
import std.algorithm;
import std.range;
import std.typecons;

void main() {
    int[] arr1 = [ 1, 2, 3, 4 ];
    int[] arr2 = [ 5, 6 ];
auto dd = map!(z => tuple(z * z, z * z * z))(chain(arr1, arr2));
    writeln(dd);
}

Ali

Thanks Ali. I think it's been around like this for a long time. I searched issue tracker but no issues of this type. Also if I need to map on a array of tuples will that work with the tuple being unpacked or do I need to get it as single element and do unpacking myself? Sorry on mobile so couldn't check.

Reply via email to