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)) 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]. For more options, visit this group at http://groups.google.com/group/sage-edu?hl=en.
