reduce()
reduce(fn, [1,2,3,4])
1
2
a = fn(1,2)
a
[1,2,3,4]
[a,3,4]
3
b = fn(a,3)
[b,4]
[c]
c = fn(b,4)
fn(x,y)
x
y
[1+2, 3, 4]
[(1+2) + 3, 4]
[((1+2)+3) + 4]
1+2+3+4
reduce(max, [1,2,3,4])
max(1,2)
[2,3,4]
max(2,3)
[3,4]
[4]
4
reduce(fn, [1,2,3,4], 5)
reduce(fn, [5,1,2,3,4])