Quick actions

cmd+k|ctrl+k

Navigation

Languages

Practice Python

Snippet info

Language

Python

Visibility

public

Author

steinwaywhw

Created

2016-07-02T03:27:09Z

Updated

2016-07-02T03:27:09Z

import operator

def foldright(xs, f, base):
    if xs == []:
        return base
    else:
        return f(xs[0], foldright(xs[1:], f, base))

ret = foldright([1,2,3,4,5], operator.add, 0)
print(ret)
INFO