def grep(word, dataset): """Returns true if word is in the dataset""" def f(data): return data == word def g(initial, possible): if initial: return True return possible return reduce(g, map(f, dataset)) > 0 dataset = ['this', 'is', 'words', 'or', 'something'] print grep('this', dataset) print grep('not', dataset)