sml - Can I fold with an infix operator without writing out an anonymous function? -
if wanted add together list this:
- list.foldr (fn (x, y) => x + y) 0 [1, 2, 3] val = 6 : int
is there way write more along lines of:
list.foldr + 0 [1, 2, 3]
i tried this:
fun inf2f op = fn (x, y) => x op y;
you're close. add together op
keyword in sec example.
- list.foldr op + 0 [1,2,3]; val = 6 : int
sml syntactic-sugar
No comments:
Post a Comment