I am trying to write a function that will essentially return a function as a result. I am trying to achieve something like this:
{{Add 3}4}
where the result will come out as 7. I found the following SO question that has the same question, but the answer did not work for me. I receive "Variable Adder not Introduced". I have tried declaring it locally, and also setting a variable equal to it, but as of yet, I have not gotten anything to work. I know what I want to do; I want to return a function that has been decorated by an outer function. Unfortunately, I can't find anything solid in the documentation on how to do that. Here is what I've been trying, based on the online docs.
declare
local
proc {And M ?B}
if M > 0 then B = M else B = 0 end
end
in
proc {Add2 J ?B}
J + {And}
end
end
When I call
{{Browse {Add2 1}2}
I'm hoping to get 3. What I actually get is a compilation with no errors, that doesn't actually browse to anything. I know this isn't what I'm looking for, but it's all i've got so far. I want to take J, and add it to the result of calling whatever is left out there. Can anyone point the way?
Thanks,
Using function:
Using procedure: