(Re)add recursion support
This commit is contained in:
parent
23892acf6d
commit
8434ac98a0
1 changed files with 8 additions and 1 deletions
9
eval.ml
9
eval.ml
|
@ -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 ->
|
||||
|
|
Loading…
Add table
Reference in a new issue