Mathematica 7 compares to other languages

Xah Lee xahlee at gmail.com
Thu Dec 11 13:41:59 EST 2008


On Dec 10, 2:47 pm, John W Kennedy <jwke... at attglobal.net> wrote:
> Xah Lee wrote:
> > In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
> > you'll have 50 or hundreds lines.
>
> C:
>
> #include <stdlib.h>
> #include <math.h>
>
> void normal(int dim, float* x, float* a) {
>     float sum = 0.0f;
>     int i;
>     float divisor;
>     for (i = 0; i < dim; ++i) sum += x[i] * x[i];
>     divisor = sqrt(sum);
>     for (i = 0; i < dim; ++i) a[i] = x[i]/divisor;
>
> }

i don't have experience coding C. The code above doesn't seems to
satisfy the spec. The input should be just a vector, array, list, or
whatever the lang supports.
The output is the same datatype of the same dimension.

  Xah
∑ http://xahlee.org/


More information about the Python-list mailing list