Python _functools.reduce() Examples

The following are 2 code examples of _functools.reduce(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module _functools , or try the search function .
Example #1
Source File: python26.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_functools_reduce():
    import _functools
    
    words = ["I", "am", "the", "walrus"]
    combine = lambda s,t: s + " " + t
    
    Assert(hasattr(_functools, "reduce"))
    
    AreEqual(_functools.reduce(combine, words), "I am the walrus")
    AreEqual(_functools.reduce(combine, words), reduce(combine, words)) 
Example #2
Source File: python26.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_functools_reduce():
    import _functools
    
    words = ["I", "am", "the", "walrus"]
    combine = lambda s,t: s + " " + t
    
    Assert(hasattr(_functools, "reduce"))
    
    AreEqual(_functools.reduce(combine, words), "I am the walrus")
    AreEqual(_functools.reduce(combine, words), reduce(combine, words))