Dear, i try convert a code to functional coding style: commented code is what i try to convert to functional
_______________________________________ import std.stdio; import std.range; import std.algorithm; import std.conv : to; import std.typecons : tuple; import std.math : sqrt, floor; import std.array : empty, array; void main( ){ immutable size_t limit = cast(size_t ) floor( sqrt( cast(double)1_000 ) ); //~ foreach( m; iota( 2, limit ) ){ //~ foreach( n; iota( 1, m-1) ){ //~ if( 2 * m * (m+n) == 1_000 ) writeln((m ^^ 2 - n ^^ 2) * (2 * m * n) * (m ^^ 2 + n ^^ 2)); //~ } //~ } auto r = iota(2, limit ) .map!( m => tuple( m, iota( 1, m - 1) .filter!( n => 2 * m * (m+n) == 1_000 ) ) ).filter!( n => !n[1].empty ); auto m = r.array[0][0]; auto n = r.array[0][1]; writeln( typeid( n ) ); writeln( n ); //~ writeln( (m ^^ 2 - n ^^ 2) * (2 * m * n) * (m ^^ 2 + n ^^ 2)); } _______________________________________ I want to compute (m ^^ 2 - n ^^ 2) * (2 * m * n) * (m ^^ 2 + n ^^ 2) when n => 2 * m * (m+n) == 1_000 I do this in 2 step maybe that is possible in one. I search to convert m and n to size_t type thanks for your help