On Sat, Jan 9, 2010 at 2:55 PM, Harald Schilly <[email protected]>wrote:
> On Jan 9, 5:22 pm, michel paul <[email protected]> wrote: > > def dot_product(row, col): return sum([r*c for (r, c) in zip(row, col)]) > > I was reading this and i just want to add a more advanced example for > that (it's a bit faster, too): > > import operator > def dot_product(row, col): return sum(map(operator.mul, row, col)) > > and spicing it with imap from itertools: > > from itertools import imap > def dot_product(row, col): return sum(imap(operator.mul, row, col)) > Thanks, this kind of stuff would be good to know about for kids experienced in programming. It's always a difficult balance in high school math - efficiently illustrating math concepts in code without pushing buttons that flash 'Warning! This is no longer math!'. In an actual computational math class this would provide an excellent example for differentiation. 'Differentiated instruction' is a big buzz word these days at my school. OK, if that's what they want, here's an example. > > h > > -- > You received this message because you are subscribed to the Google Groups > "sage-edu" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<sage-edu%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/sage-edu?hl=en. > > > >--
You received this message because you are subscribed to the Google Groups "sage-edu" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/sage-edu?hl=en.
