On Thu, 11 Dec 2008 05:40:45 +0000 Paul Rudin <[EMAIL PROTECTED]>
wrote:

> "Dotan Cohen" <[EMAIL PROTECTED]> writes:
> 
> > 2008/12/10  <[EMAIL PROTECTED]>:
> >> Ruby:
> >>
> >> def norm a
> >>  s = Math.sqrt(a.map{|x|x*x}.inject{|x,y|x+y})
> >>  a.map{|x| x/s}
> >> end
> >
> > If someone doesn't counter with a Python one-liner then I'm going to
> > port that to brainfuck.
> 
> from numpy.linalg import norm
> 
> :)

This is one line of Python code alright, but it's not a "one-liner" in
the "computes the a normalized vector"-sense (which was the original
challenge, if there ever was one).

If anything, you are now ready to compute the *norm* of a vector in a
subseqent line. (Or, if you must, after a semicolon on the same line.)

:)
/W

-- 
My real email address is constructed by swapping the domain with the
recipient (local part).
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to