(* This file is part of our reusable OCaml BRICKS library
Copyright (C) 2007 Jean-Vincent Loddo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(** Poor man fix point operators. *) |
(** Basic fix point operators.
Example: *) |
let rec fix f =
f (fun x -> (fix f) x);;
(** Fix point operator for making function requiring a parameter (the "environment").
Example: *) |
let rec efix f e =
(f e) (fun y x -> (efix f y) x);;
(** Fix point operator with an environment and a treatment (a "cure")
to perform before each recursive call. The typical example is
the "memoisation" cure useful for making memoised functions defined
by a recursive definition (each recursive call must share the same
hash table).
Example: *) |
let rec ecfix c f e =
(fun g -> c ((f e) g)) (fun y x -> (ecfix c f y) x);;