Andreas Waldenburger wrote:
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.)

Couldn't we assume that when you doing these kinds of math, there's always
import numpy
  or
from numpy import *

is always at the start of the program, so it doesn't belong to the functional code ?

And for those who use VPython (and thus needs " from visual import *" )
can simply do
 a = norm ( v )

cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to