On Sunday, 6 January 2013 at 15:39:03 UTC, Lobachevsky wrote:
Is there any plan to extend array-wise expressions to include calls to arbitrary "scalar" functions, i.e.

auto a = [1.2, 2.3, 3.4];
auto b = [7.1, 8.2, 9.3];
auto c = new double[3];
c[] = sin( 4 * a[] + b[] );

or

c[] = foo(a[], b[], 42);

Performing this action would require several calls to foo. By convention, array operations aren't loops; it only calculates the R-value once, then sets all elements to the same value. I wrote this as a quick example:

http://dpaste.dzfl.pl/4ba03ef6

It does get a random value, but it only calls rand() once so all of the elements in the array are set to the same random value.

Reply via email to