3 ms·
How is a for-loop not a fold?
by gue5t 9y ago
How is a for-loop not a fold?
- JBiserkov 9y agoA fold is usually restricted to a combining function of 2 arguments - accumulated-so-far and current item. A for-loop's body has no such restrictions, it can access any number of neighbor elements if the algorithm so requires. a[i] = a[i-1] * a[i+1]
- rjeli 9y agoA for loop is a fold over the local context and the index