[ create a new paste ] login | about

Link: http://codepad.org/0pYfWqSF    [ raw code | output | fork ]

Python, pasted on Sep 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import operator

def lrange(a, b, f):
    num = a
    comp = operator.lt if (a < b) else operator.gt

    while comp(num, b):
        yield num
        num = f(num)

for x in lrange(1, 1025, lambda x: x*2):
    print(x)

print

for x in lrange(35926661, 0, lambda x: x>>6):
    print(x)


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
4
8
16
32
64
128
256
512
1024

35926661
561354
8771
137
2


Create a new paste based on this one


Comments: