mroussel@alchemy.chem.utoronto.ca (Marc Roussel) (06/18/91)
Over the last few years of programming in Fortran, I have built up a small personal library of useful functions and subroutines. I try very hard to make every line of code in my library standard-conforming, or at least only to use extensions like INCLUDE, and DO..ENDDO which everyone supports and which will wind up in Fortran 90 anyway. That way, when the inevitable happens and we abandon our current hardware and its compiler, I won't have too much trouble taking my library with me. Having said that, I am looking for a standard-conforming way to pass a functional composition to a subroutine. Personally, I can't think of any save writing special-purpose single-use interface routines. In case it's not clear what I want, consider the following trivial example: FUNCTION FOO(F,X) 1 foo = f(x) END If I have a function F(X) somewhere else in my program, this works marvelously. How do I (can I) deal with the case where I want F to be a composition of two functions so that the effect of line 1 would be to assign foo to f(g(x))? Ideally, it would be as simple as calling FOO with something like answer = foo(comp(f,g),x) where COMP is some suitably written composition operator. My gut says this isn't possible in Fortran 77, but then every time I think something like that, someone shows me a bit of the language I knew nothing about :-). Marc R. Roussel mroussel@alchemy.chem.utoronto.ca