Understanding Continuation Passing Style

I suspect the implementation in the OCaml Pro post has a typo, and that it should be

(* Tail-recursive CPS implementation of map *)
let rec map_cps f l k =
  match l with
  | [] -> k []
  | x :: r ->  let fx = f x in map_cps f r (fun r -> k (fx :: r))
;;

With the continuation applied to the cons in the closure.

EDIT: re:

This is also very common in OCaml, and AFAIK, it is the more idiomatic approach if your aim is just to get a tail-call position version of these kinds of functions. That approach an accumulator argument rather than a continuation argument. See What is the use of Continuation Passing Style (CPS)? for related discussion.

(I also removed a link to a likely LLM spam source. Sorry about missing that initially!)