List-ops: foldr and order of arguments

The description says

Note, the ordering in which arguments are passed to the fold functions (foldl, foldr) is significant.

but the canonical tests disagree:

  • foldl “direction dependent function applied to non-empty list”
             "function": "(acc, el) -> el / acc"
    
  • foldr “direction dependent function applied to non-empty list”
             "function": "(acc, el) -> el / acc"
    

Does that note still make sense?

The note doesn’t say what order the arguments are passed in. Just that the order is significant. I think it’s still accurate and relevant.

Oh right. I was reading that as “the order for foldl is different from foldr” but it doesn’t say that at all…

The note is technically correct, but it might be a bit confusing, e.g. if you implement it in multiple tracks. In some, this can be read as glennj did, because the arguments order is different for the two functions.

Various language tracks seem to treat this differently, from what I’ve seen. More or less naturally following the language’s idioms, I suppose.

I’m really not sure if detailing the note would help.

Examples follow, in case they’d help. Links are to the source of the exercise or test, depending what I thought it makes the point easier.

In Haskell (obviously) and eLisp, the arguments are actually reversed.

Python, expects both functions to have the accumulator first, while C and Elixir expect them both to have the accumulator as the second argument.

Finally in Ruby they don’t have these at all (being replaced, rather awkwardly IMHO, with two “reducers” that both work naturally left to right – but don’t know Ruby, more than to casually solve some exercises, so there might be reasons for this).