home *** CD-ROM | disk | FTP | other *** search
- /* Example Apply */
- /* functions and vectors can be arguments or components */
-
- apply(pair)
- {
- return pair[function](pair[argument]);
- }
-
- f(x) // f takes functions as arguments
- { return x(0); }
-
- g(x)
- { return (100+x); }
-
- main()
- {
- enum { function, argument };
- x = vector { f; g; }; // a vector of functions
- print(apply(x),"\n");
- }
-