Consider function g gets integer and returns true if the integer is bigger than some random const positive value that was decided before, otherwise false.
I would like to write a function f in SML which gets the function g as argument. this function f should return this random const positive value that was decided before.
Algorithm (In some other language, C or something):
int f(int num) {
int num = 1;
while(!g(num)) {
num++;
}
return num;
}
Now this is what I tried in SML:
fun f g =
let
val num = 1;
in
while !(g num) do (
val num = num + 1;
);
num
end;
But it doesn't work. Any suggestions?
int f(bool (*g)(int)) {..., right? - sepp2k