In Standard ML, foldl doesn’t flip the order of operands vs foldr. It’s always operand from list first, then init or accumulator second, whether folding left or right. From the Standard ML Basis (and every textbook I’ve looked at):

`foldl f init [x1, x2, ..., xn]`

returnsf(xn,…,f(x2, f(x1, init))…)

or init if the list is empty.

`foldr f init [x1, x2, ..., xn]`

returnsf(x1, f(x2, …, f(xn, init)…))

or init if the list is empty.

(In Haskell, and maybe elsewhere, they flip, right? If this exercise is also in the Scheme track, it should probably be checked too, since it seems Scheme is like SML here.)

Thus `foldl (op div) 5 [2, 5]`

(one of the test cases – but with the arguments as a tuple instead of curried) raises an exception for division by zero, but the test expects this to yield 0. The evalution goes 2 div 5 = 0, then 5 div 0, exception; not 5 div 2 = 2, then 2 div 5 = 0.

You can pass the tests if you write Haskell’s foldl instead SML’s, but that seems like a bad idea since the definition of *Standard* ML is famously not up for grabs.