(Re)add recursion support

This commit is contained in:
백현웅 2022-02-13 21:10:25 +09:00
parent 23892acf6d
commit 8434ac98a0

View file

@ -285,7 +285,14 @@ let rec eval env ast =
begin match args with
| [] -> f
| a::args ->
let env = Env.bind (var, aux a) env in
let itself = match v with Var v -> Some v | _ -> None in
let env =
(* binding itself into env for recursion *)
Option.fold
~none: env ~some: (fun v -> Env.bind (v, f) env)
itself
|> Env.bind (var, aux a)
in
eval env @@ Apply (e, args)
end
| External f ->