On Dec 10, 2:47 pm, John W Kennedy <jwke...@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/

☄
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to