2017-03-31 | Paul Boddie | file changeset files shortlog | Fixed non-recognition of deferred references in non-module, non-function scopes. |
paul@141 | 1 | def f(a, b, c): |
paul@141 | 2 | return a and b and c |
paul@141 | 3 | |
paul@141 | 4 | def g(a, b, c): |
paul@141 | 5 | return a or b or c |
paul@141 | 6 | |
paul@141 | 7 | def h(a, b, c): |
paul@141 | 8 | return a and b or c |
paul@141 | 9 | |
paul@141 | 10 | def i(a, b, c): |
paul@141 | 11 | return a or b and c |
paul@141 | 12 | |
paul@141 | 13 | def j(a, b, c): |
paul@141 | 14 | return f(a, b, c) and g(a, b, c) or c |
paul@202 | 15 | |
paul@372 | 16 | print f(0, 0, 0) # 0 |
paul@372 | 17 | print f(1, 0, 1) # 0 |
paul@372 | 18 | print f(1, 1, 1) # 1 |
paul@372 | 19 | |
paul@372 | 20 | print g(0, 0, 0) # 0 |
paul@372 | 21 | print g(1, 0, 0) # 1 |
paul@372 | 22 | print g(0, 0, 1) # 1 |
paul@372 | 23 | |
paul@372 | 24 | print h(0, 0, 0) # 0 |
paul@372 | 25 | print h(0, 0, 1) # 1 |
paul@372 | 26 | print h(1, 0, 0) # 0 |
paul@372 | 27 | |
paul@372 | 28 | print i(0, 0, 0) # 0 |
paul@372 | 29 | print i(0, 0, 1) # 0 |
paul@372 | 30 | print i(1, 0, 0) # 1 |
paul@372 | 31 | |
paul@372 | 32 | print j(0, 0, 0) # 0 |
paul@372 | 33 | print j(0, 0, 1) # 1 |
paul@372 | 34 | print j(1, 0, 0) # 0 |
paul@372 | 35 | |
paul@372 | 36 | # Test any and all functions. |
paul@372 | 37 | |
paul@372 | 38 | l = [0, 0, 1, 0, 0] |
paul@372 | 39 | print any(l) # True |
paul@372 | 40 | print all(l) # False |
paul@372 | 41 | |
paul@372 | 42 | l = [1, 1, "one", 1] |
paul@372 | 43 | print any(l) # True |
paul@372 | 44 | print all(l) # True |
paul@372 | 45 | |
paul@372 | 46 | l = [1, 1, "one", ""] |
paul@372 | 47 | print any(l) # True |
paul@372 | 48 | print all(l) # False |