Xah Lee wrote: >> >On Dec 10, 2:47 pm, John W Kennedy <jwke...@attglobal.net> wrote: >> >> 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; >> >> >> } > > Due to the low level of C, this C example should perhaps then accept a > sequence of numbers separated by space...
In other words, you want a REPL. Why don't we have another challenge that involves handling a non-trivial input format, i.e. parsing? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listinfo/python-list