Draft web text re vectors, quadrays, python, spatial geometry, crystallography, peer review solicited

Peter Schneider-Kamp petersc at stud.ntnu.no
Sat May 27 16:21:35 EDT 2000


Kirby Urner wrote:
> 

Hei Kirby!

I do not know what your preferences for the source code, but
there is more than one way to do the example below (do I sound
like some p&rl-monkey?):

E.g. using map and reduce:

from operator import add,mul
def dot(self,v1):
  return reduce(add,map(mul,self.norm0(),v1.norm0()))

This might look unreadable to many people, but for others
(with a functional programming background) it looks clearer.

So it's a matter of taste/preferences, I guess.

>     def dot(self,v1):
>         # return the dot product of self with another vector
>         # return a scalar
>         scalar = 0
>         a = self.norm0()
>         b = v1.norm0()
>         for i in range(4):
>             scalar = scalar + a[i] * b[i]
>         return 0.5*scalar

greeting-the-lisp-fellows-ly y'rs
Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de




More information about the Python-list mailing list