Beispiel #1
0
def minby(f, l):
    best, bestval = car(l), f(car(l))
    for x in cdr(l):
        val = f(x)
        if val < bestval:
            best, bestval = x, val
    return best
Beispiel #2
0
def pairwise(l):
    'Only works for lists up to 1000 in size. snide Python comment goes here'
    if not l:
        return []
    else:
        return [(car(l),x) for x in cdr(l)] + pairwise(cdr(l))