4 ms·
> of course, fold right is the more general operator, as you can implement fold left in terms of fold right. The other way works too: fold right can be impleme
by mkeoliya 4y ago
> of course, fold right is the more general operator, as you can implement fold left in terms of fold right.
The other way works too: fold right can be implemented in terms of fold left. Here's an approach using continuations in OCaml:
let fold_right f z xs = (List.fold_left (fun kont x -> (fun y -> kont (f x y))) Fun.id xs) z;;
- deleted 4y ago[deleted]