From b75d48cff994c03f6b241a61393a9798b52d6f0d Mon Sep 17 00:00:00 2001 From: neingeist Date: Thu, 4 Sep 2014 18:14:51 +0200 Subject: [PATCH] map and multiple lists --- mapreduce.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 mapreduce.py diff --git a/mapreduce.py b/mapreduce.py new file mode 100644 index 0000000..1ca9910 --- /dev/null +++ b/mapreduce.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +from __future__ import division, print_function + +import operator + +seq1 = [1, 2, 3] +seq2 = ["eins", "zwei", "drei", "vier"] +map(lambda x: print("got:", x), seq1) +map(lambda x1, x2: print("got:", x1, x2), seq1, seq2) +map(lambda *x: print("got:", x), seq1, seq2) +print(map(None, seq1, seq2)) + +seq3 = [1, 2, 3, 4] +print(reduce(operator.mul, seq3))