Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum(f: Int => Int, a: Int, b: Int): Int = {
- def loop(a: Int, acc: Int): Int = {
- if (a>b) acc
- else loop(a+1, f(a)+acc)
- }
- loop(a, 0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement