All pastes #621954 Raw Edit

Stuff

public text v1 · immutable
·published 2007-07-16 15:15 UTC
rendered paste body
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)