Is it possible to reset using an infix operator without writing out an anonymous function?

If I wanted to add a list, I could do this:

- List.foldr (fn (x, y) => x + y) 0 [1, 2, 3]
val it = 6 : int

Is there a way to write something more line by line:

List.foldr + 0 [1, 2, 3]

I tried something like this:

fun inf2f op = fn (x, y) => x op y;
+5
source share
1 answer

You're close Add a keyword opin the second example.

- List.foldr op + 0 [1,2,3];
val it = 6 : int
+7
source

All Articles