This language bar is your friend. Select your favorite languages!

Idiom #208 Formula with arrays

Given the arrays / lists a,b,c,d (assumed to be of equal length) and the scalar e, calculate a = e*(a+b*c+cos(d)). Use the old value for a for all calculations.

a =,c,d).map{|i,j,k,l| e*(i+j*k+Math::cos(l)) }
#include <math.h>
  for (i=0; i<n; i++)
    a[i] = e*(a[i]+b[i]*c[i]+cos(d[i]);
a = e*(a+b*c+cos(d))
for i := 0 to High(a) do
    a[i] = e*(a[i]+b[i]*c[i]+cos(d[i]);
$a[$_] = $e * ($a[$_] + $b[$_] * $c[$_] + cos $d[$_]) for 0 .. $#a;
import math
for i in xrange(len(a)):
	a[i] = e*(a[i] + b[i] + c[i] + math.cos(a[i]))

Do you know the best way to do this in your language ?
New implementation...

Idiom created by