I'm trying to implement the following with OCaml for a homework assignment:
g(n) = y if n = x else f(n)
so, for example
if f(n) = n+1, x = 7, y=42, then g(1) = 2, but g(7) = 42
I've got:
# let update f x y = f(x) = y;;
val update : ('a -> 'b) -> 'a -> 'b -> bool = < fun>
but I just don't know the syntax I should use in order to make it return a function instead of a boolean value.
I'm not asking for someone to solve the problem, but if someone could post some code that takes in a function, manipulates it, and returns it, I'd appreciate it.