Example #1
0
def embedly1():
    print ftake(ffilter(lambda n: n[0] == 8001, R_seq()), 1)[0][1]
Example #2
0
def embedly1():
    print ftake(ffilter(lambda n: n[0] == 8001, R_seq()), 1)[0][1]
Example #3
0
#sys.path.append('') #for emacs
from lazy import ftake, ffilter

oneTo = lambda n: range(1, n+1)
assert [1,2,3,4,5] == oneTo(5)

def count_seq():
    "partial implentation of itertools.count"
    def _():
        _.i += 1
        return _.i
    _.i = 0
    return _

assert [1,2,3,4,5] == ftake(count_seq(), 5)


def fac_seq():
    def _():
        _.count += 1
        _.acc *= _.count
        return _.acc
    _.acc = 1
    _.count = 0
    return _

assert [1, 2, 6, 24, 120] == ftake(fac_seq(), 5)

def reduce_seq(f, fnext, acc):
    def _():
Example #4
0
oneTo = lambda n: range(1, n + 1)
assert [1, 2, 3, 4, 5] == oneTo(5)


def count_seq():
    "partial implentation of itertools.count"

    def _():
        _.i += 1
        return _.i

    _.i = 0
    return _


assert [1, 2, 3, 4, 5] == ftake(count_seq(), 5)


def fac_seq():
    def _():
        _.count += 1
        _.acc *= _.count
        return _.acc

    _.acc = 1
    _.count = 0
    return _


assert [1, 2, 6, 24, 120] == ftake(fac_seq(), 5)