Instantly share code, notes, and snippets.

View MapReduceStream.java
final int s = ImmutableList.of(1, 2, 3)
.stream()
.map(x -> x * 2)
.reduce(0, (x, y) -> x + y);
View MapReduceList.scala
val s = List(1, 2, 3) map (_*2) reduce (_+_)
View inverted_index.py
from collections import defaultdict
T = {'1' : ' payday', '2' : 'mayday mayday', '3' : 'day may'}
index = defaultdict(set)
# create 5-shingles
for k, v in T.items():
for i in range(len(v) - 4):
index[v[i:i+5]].add(k)